Python CTC损耗计算错误
Python的输入:Python CTC损耗计算错误,python,tensorflow,ctc,Python,Tensorflow,Ctc,Python的输入: sequence1 = [0, 1] output1 = [[1, 0, 0],[0, 1, 0]] loss = tf.compat.v1.nn.ctc_loss( labels=tf.sparse.from_dense([sequence1]), inputs=np.array([output1]).astype('float32'),
sequence1 = [0, 1]
output1 = [[1, 0, 0],[0, 1, 0]]
loss = tf.compat.v1.nn.ctc_loss(
labels=tf.sparse.from_dense([sequence1]),
inputs=np.array([output1]).astype('float32'),
sequence_length=[2],
time_major = False
)
print(loss.numpy())
Python的输出:
array([1.2408944], dtype=float32)
0.
Mathematica的输入:
CTCLossLayer[<|
"Input" -> {{1, 0, 0}, {0, 1, 0}},
"Target" -> {1, 2} (* Index starts from 1 and not 0 *)
|>]
既然我的序列是[0,1]
,它是一个热编码(当字符数为2+1时(对于CTC))是[[1,0,0],[0,1,0]]
-那么nn.CTC\u损失
不应该是0
?就像在Mathematica?谢谢