dynamic_simple_soft_distraction_model.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:diversity_based_attention 作者: PrekshaNema25 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号