python - InvalidArgumentError in Tensorflow -
i`m trying create neural network using tensorflow tools.
sizeofrow = len(data[0]) x = tensorflow.placeholder("float", shape=[none, sizeofrow]) y = tensorflow.placeholder("float") def neuralnetworktrain(x): prediction = neuralnetworkmodel(x) # using softmax function, normalize values range(0,1) cost = tensorflow.reduce_mean(tensorflow.nn.softmax_cross_entropy_with_logits(prediction, y)) this part net have got error:
invalidargumenterror (see above traceback): logits , labels must same size: logits_size=[500,2] labels_size=[1,500] [[node: softmaxcrossentropywithlogits = softmaxcrossentropywithlogits[t=dt_float, _device="/job:localhost/replica:0/task:0/cpu:0"](reshape, reshape_1)]] someone know what`s wrong?
edit: have got code:
for temp in range(int(len(data) / batchsize)): ex, ey = takenextbatch(i) # takes 500 examples += 1 # to-do : fix bug here temp, cos = sess.run([optimizer, cost], feed_dict= {x:ex, y:ey}) this error typeerror: unhashable type: 'list'
well, error quite self-describing.
logits , labels must same size: logits_size=[500,2] labels_size=[1,500]
so, first, labels should transposed have size 500, 1 , second, softmax_cross_entropy_with_logits expects labels presented in form of probability distribution (e.g. [[0.1, 0.9], [1.0, 0.0]]).
if know classes exclusive (which case), should switch using sparse_softmax_cross_entropy_with_logits.
Comments
Post a Comment