Keras tensorflow诡异损失精度

2024-10-17 00:30:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我开发了一个cnn+lstm网络,输入一个向量(音频音轨),每个音轨都有一个特定的情感标签,叫做唤醒和配价。
我必须使用一个称为一致性相关系数的定制损失函数,当我评估预测值和测试值之间的损失值时,我得到大约99%的值,但是如果我绘制信号,它们就太不一致了。在

下面是代码的一部分,我采取一个音频轨道,并为他们每一个我采取一个分段训练模型。每个片段都有一个特定的唤醒价标签。在

for t in range(0, train_set.shape[0]):
    print('Traccia audio: ' + str(t+1))
    track = np.expand_dims(train_set[t], axis=2) # shape: (50, 96000, 1) 
    label_arousal = strided_app(train_arousal[t], 96000, 96000) # shape: (50, 96000)
    label_valence = strided_app(train_valence[t], 96000, 96000)
    for s in range(0, track.shape[0]):
        sub_track = np.expand_dims(track[s], axis=0) # shape: (1, 96000, 1)
        sub_arousal = np.expand_dims(label_arousal[s], axis=0) # shape: (1, 96000)
        sub_valence = np.expand_dims(label_valence[s], axis=0)
        model.fit(sub_track, [sub_arousal, sub_valence], batch_size=50, epochs=10, verbose=0)  

这是损失值(百分比)

^{pr2}$

这里的情节,例如,一个音轨的预测和唤醒测试

enter image description here

更新:

总是很奇怪。。。在

Traccia: 1
Arousal: 99.32691103454766
Valence: 99.30587783543801
************
Traccia: 2
Arousal: 99.63365628935205
Valence: 100.80776034855722
************
Traccia: 3
Arousal: 100.03581897568333
Valence: 99.54317949248193
************
Traccia: 4
Arousal: 99.64728586766705
Valence: 100.4571474364673
************
Traccia: 5
Arousal: 98.83308475135347
Valence: 100.00826448944555
************
Traccia: 6
Arousal: 99.23057248056854
Valence: 99.35969107562337
************
Traccia: 7
Arousal: 102.02497484030464
Valence: 99.9984707880692
************
Traccia: 8
Arousal: 99.81442313624571
Valence: 99.73086051788052
************
Traccia: 9
Arousal: 99.94000790770609
Valence: 99.54597275339133
************
Traccia: 10
Arousal: 99.32234708421316
Valence: 100.11396967864196
************
Traccia: 11
Arousal: 98.9037260945822
Valence: 99.67784995505049
************
Traccia: 12
Arousal: 100.17597068985451
Valence: 100.06106830968153
************

新的情节呢

enter image description here


Tags: nptraintracklabelexpand损失shapeaxis