def loss_op(self, outputs, labels, weights, len_vocab):
""" Calculate the loss from the predicted outputs and the labels
Args:
outputs : A list of tensors of size [batch_size * num_symbols]
labels : A list of tensors of size [sequence_length * batch_size]
Returns:
loss: loss of type float
"""
_labels = tf.unpack(labels)
all_ones = [tf.ones(shape=tf.shape(_labels[0])) for _ in range(len(_labels))]
weights = tf.to_float(weights)
_weights = tf.unpack(weights)
#print(_weights[0].get_shape())
loss_per_batch = sequence_loss(outputs, _labels, _weights)
self.calculated_loss = loss_per_batch
return loss_per_batch
dynamic_m1_model.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录