2016-02-13 14 views
9

ottengo seguente erroreerrore nel calcolo tensorflow croce perdita di entropia

ValueError: Tensor conversion requested dtype float32 for Tensor with dtype int32: 'Tensor("Placeholder_1:0", shape=TensorShape([Dimension(128), Dimension(2)]), dtype=int32)' 

quando cerco di calcolare la perdita di entropia croce

losses = tf.nn.softmax_cross_entropy_with_logits(scores, input_y) 

io uso Python 3.4.3.

Qualche idea, perché?

risposta

16

Sembra che tu abbia definito input_y -che io presumo che sia un tf.placeholder() -come tipo tf.int32. Cambialo in tf.float32 o aggiungi un cast: tf.cast(input_y, tf.float32) o tf.to_float(input_y).

+0

Grazie, il casting ha risolto il problema. – anamar

+0

non riesco a trovare cast o to_float in tflearn, quale modulo dobbiamo importare? – f3n1Xx

+0

'tf.cast()' e 'tf.to_float()' sono le funzioni di TensorFlow, quindi le useresti usando 'import tensorflow as tf'. – mrry

Problemi correlati