Reputation: 157
Hi i'am currently trying to run TensorFlow with own image data. But it crashes when i'am trying to run these function: its from mnist.py
def loss_fn(logits, labels):
batch_size = tf.size(labels)
labels = tf.expand_dims(labels, 1)
indices = tf.expand_dims(tf.range(0, batch_size, 1), 1)
concated = tf.concat(1, [indices, labels])
onehot_labels = tf.sparse_to_dense(
concated, tf.pack([batch_size, NUM_CLASSES]), 1.0, 0.0)
cross_entropy = tf.nn.softmax_cross_entropy_with_logits(logits,
onehot_labels,name='xentropy')
loss = tf.reduce_mean(cross_entropy, name='xentropy_mean')
return loss
with this error:
Compute status: Invalid argument: Indices are not valid (out of bounds). Shape: dim { size: 100 } dim { size: 447 }
the number 100 is my batch_size and 447 is my number of classes.
i also try to solve that issue like here https://github.com/tensorflow/tensorflow/issues/194 changing the indeces line into this line:
indices = tf.expand_dims(tf.range(0, batch_size, 1), 1)
didn't solve my problem. Does anybody have an idea?
Upvotes: 2
Views: 5863