def loss_graph(logits, batch_size, num_unroll_steps):
with tf.variable_scope('Loss'):
targets = tf.placeholder(tf.int64, [batch_size, num_unroll_steps], name='targets')
# target_list = [tf.squeeze(x, [1]) for x in tf.split(1, num_unroll_steps, targets)]
target_list=tf.unpack(targets, axis=1)#hjq
loss= tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(logits, target_list), name='loss')
# reduce_mean to reduce_sum,hjq
return adict(
targets=targets,
loss=loss
)
评论列表
文章目录