训练lstm+crf模型时出现以上错误:
- 直接使用不会报错
for i in range(per_epochs):
for x,y in dataset.take(1):
with tf.GradientTape() as tape:
print(i)
pre = model(x)
mask = tf.greater(x,0)
l = loss(y,pre,mask)
print(l)
但crf层前的梯度为None - 使用以下会报错
model.fit(dataset,epochs,steps_per_step)