what does it mean having a negative cost for my training set?

I'm trying to train my model and my cost output decreases each epoch till it reaches a values close to zero then goes to negative values I'm wondering what is the meaning of having negative cost output ?

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

I'm training using tensorflow it's a simple neural network with 2 hidden layers ,learning_rate =0.0001, number_of_epoch=30, mini-batch_size=50, train-test-ratio=69/29 and all the data set is of 101434 training examples Cost is computes using cross entropy equation

tf.nn.sigmoid_cross_entropy_with_logits(logits=Z3, labels=Y)

It means the labels are not in the format in which the cost function expects them to be.

Each label that is passed to sigmoid_cross_entropy_with_logits should be 0 or 1 (for binary classifcation) or a vector containing 0's and 1's (for more than 2 classes). Otherwise, it won't work as expected.

For n classes, the output layer should have n units, and the labels should be encoded as such before passing them to sigmoid_cross_entropy_with_logits :

Y = tf.one_hot(Y, n)

This assumes that Y is a list or one-dimensional array of labels ranging from 0 to n-1 .

链接地址: http://www.djcxy.com/p/32132.html

上一篇: 张量流中的值误差

下一篇: 这对我的训练集有什么负面影响?