Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用可变长度选项实现softmax损耗_Python_Tensorflow_Sequences - Fatal编程技术网

Python 如何使用可变长度选项实现softmax损耗

Python 如何使用可变长度选项实现softmax损耗,python,tensorflow,sequences,Python,Tensorflow,Sequences,我试图在tensorflow上实现drqa模型,在这里我将预测答案子串的开始和结束位置。所以有[批量大小,最大时间]的概率输出,对应的上下文序列。现在我想应用softmax交叉焓损失,但序列是零填充的。所以我不想让填充物计入损失。对于如何实施这一点,是否有一些建议?谢谢。使用砝码 tf.losses.softmax_cross_entropy( labels, logits, weights=[1.]* actual_length + [0.]* (max_length - actu

我试图在tensorflow上实现drqa模型,在这里我将预测答案子串的开始和结束位置。所以有[批量大小,最大时间]的概率输出,对应的上下文序列。现在我想应用softmax交叉焓损失,但序列是零填充的。所以我不想让填充物计入损失。对于如何实施这一点,是否有一些建议?谢谢。

使用砝码

tf.losses.softmax_cross_entropy(
  labels,
  logits,
  weights=[1.]* actual_length + [0.]* (max_length - actual_length)
)

您需要添加一些代码来显示您的努力。