【问题标题】:Keras tensorflow weird loss accuracyKeras tensorflow 奇怪的损失精度
【发布时间】:2018-07-26 01:55:42
【问题描述】:

我开发了一个 cnn + lstm 网络,它接受输入一个向量(音轨),每个音轨都有一个特定的情感标签,称为唤醒和效价。
我必须使用一个名为 Concordance 相关系数的自定义损失函数,当我评估预测值和测试值之间的损失值时,我得到了大约 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)  

这里有损失值(百分比)

def ccc(x,y):

    x_mean = np.mean(x)
    y_mean = np.mean(y)

    x_var = np.var(x)
    y_var = np.var(y)

    x_std = np.std(x)
    y_std = np.std(y)

    cov = np.mean((x - x_mean) * (y - y_mean))

    numerator = 2 * cov * x_std * y_std

    denominator = x_var + y_var + (x_mean - y_mean) ** 2

    return (1 - numerator / denominator) * 100

for i in range(0, test_predictions_arousal.shape[0]):
    print('Traccia: ' + str(i+1))
    print('Arousal: ' + str(ccc(test_predictions_arousal[i], test_arousal[i])))
    print('Valence: ' + str(ccc(test_predictions_valence[i], test_valence[i])))
    print('************')

Traccia: 1
Arousal: 99.80387506604289
Valence: 99.99019742174045
************
Traccia: 2
Arousal: 99.90842777974784
Valence: 99.9833303193375
************
Traccia: 3
Arousal: 99.76175122350213
Valence: 99.91642446964116
************
Traccia: 4
Arousal: 99.69400971227803
Valence: 99.891768388332
************
Traccia: 5
Arousal: 99.64917025899855
Valence: 99.969865063012
************
Traccia: 6
Arousal: 100.31583120034135
Valence: 99.98139694474082
************
Traccia: 7
Arousal: 100.16018557121733
Valence: 99.98091831524982
************
Traccia: 8
Arousal: 99.9220169028413
Valence: 99.92336499923937
************
Traccia: 9
Arousal: 99.77060632255042
Valence: 100.03949036228647
************
Traccia: 10
Arousal: 100.0516664130463
Valence: 99.97031137929211
************
Traccia: 11
Arousal: 99.87796570089475
Valence: 99.98977148177909
************
Traccia: 12
Arousal: 99.40358994929626
Valence: 99.95646624327337
************

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

更新:

总是很奇怪……

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
************

还有新剧情

【问题讨论】:

    标签: python tensorflow keras


    【解决方案1】:

    您在应该是相关的地方使用协方差。 尝试简单:

    numerator = 2 * cov 
    

    【讨论】:

    • 公式为:Lc = 1 - rho = 1 - (2 * cov(x,y)) / (var(x) + var(y) + (E(x) - E (y))^2) 所以我需要使用协方差
    • 啊,是的,现在我尝试训练新的价值观
    • 确实,这就是我的意思:如果您使用 cov,请不要乘以 stds。
    • 好的,但很可能在情节中这两个信号是如此不一致
    猜你喜欢
    • 1970-01-01
    • 2018-06-25
    • 2020-07-10
    • 2019-11-10
    • 2017-12-24
    • 1970-01-01
    • 2017-02-20
    • 2021-09-06
    • 2019-03-25
    相关资源
    最近更新 更多