我正在尝试训练我的模型,我的成本输出会减少每个时期,直到达到接近零的值然后变为负值 我想知道负成本输出的含义是什么?
Cost after epoch 0: 3499.608553
Cost after epoch 1: 2859.823284
Cost after epoch 2: 1912.205967
Cost after epoch 3: 1041.337282
Cost after epoch 4: 385.100483
Cost after epoch 5: 19.694999
Cost after epoch 6: 0.293331
Cost after epoch 7: 0.244265
Cost after epoch 8: 0.198684
Cost after epoch 9: 0.156083
Cost after epoch 10: 0.117224
Cost after epoch 11: 0.080965
Cost after epoch 12: 0.047376
Cost after epoch 13: 0.016184
Cost after epoch 14: -0.012692
Cost after epoch 15: -0.039486
Cost after epoch 16: -0.064414
Cost after epoch 17: -0.087688
Cost after epoch 18: -0.109426
Cost after epoch 19: -0.129873
Cost after epoch 20: -0.149069
Cost after epoch 21: -0.169113
Cost after epoch 22: -0.184217
Cost after epoch 23: -0.200351
Cost after epoch 24: -0.215847
Cost after epoch 25: -0.230574
Cost after epoch 26: -0.245604
Cost after epoch 27: -0.259469
Cost after epoch 28: -0.272469
Cost after epoch 29: -0.284447
我正在使用tensorflow训练它是一个有2个隐藏层的简单神经网络 ,learning_rate = 0.0001,number_of_epoch = 30,mini-batch_size = 50,train-test-ratio = 69/29,所有数据集均为101434个训练样例 使用交叉熵方程计算成本
tf.nn.sigmoid_cross_entropy_with_logits(logits=Z3, labels=Y)
答案 0 :(得分:1)
这意味着标签的格式不是成本函数所期望的格式。
传递给sigmoid_cross_entropy_with_logits
的每个标签应为0或1(对于二进制分类)或包含0&1和1(对于2个以上的类)的向量。否则,它不会按预期工作。
对于n
类,输出图层应该有n
个单位,标签应该在将它们传递给sigmoid_cross_entropy_with_logits
之前进行编码:
Y = tf.one_hot(Y, n)
这假设Y是从0
到n-1
的列表或一维标签数组。