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'),
sequence_length=[2],
time_major = False
)
print(loss.numpy())
Python的输出:
array([1.2408944], dtype=float32)
Mathematica 的输入:
CTCLossLayer[<|
"Input" -> {{1, 0, 0}, {0, 1, 0}},
"Target" -> {1, 2} (* Index starts from 1 and not 0 *)
|>]
Mathematica 的输出:
0.
由于我的序列是[0,1]
并且它是一种热编码(当字符数为 2 + 1(对于 CTC)时)是[[1,0,0],[0,1,0]]
- 不nn.ctc_loss
应该0
吗?和数学一样?谢谢!