类型错误:"SelectV2"操作的输入"e"的类型 int64 与参数"t"的类型 int32 不匹配



我正试图用另一个名为AraBART的模型和另一个名为xlsum的阿拉伯数据集来遵循这一点。当执行这个指令时,我得到一个错误:

model.fit(
train_dataset, validation_data=validation_dataset, epochs=1
)

错误:

TypeError: in user code:
/opt/conda/lib/python3.7/site-packages/keras/engine/training.py:853 train_function  *
return step_function(self, iterator)
/opt/conda/lib/python3.7/site-packages/transformers/modeling_tf_utils.py:1279 run_call_with_unpacked_inputs  *
return func(self, **unpacked_inputs)
/opt/conda/lib/python3.7/site-packages/transformers/models/mbart/modeling_tf_mbart.py:1300 call  *
labels = tf.where(
/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py:206 wrapper  **
return target(*args, **kwargs)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py:4716 where_v2
return gen_math_ops.select_v2(condition=condition, t=x, e=y, name=name)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/gen_math_ops.py:8912 select_v2
"SelectV2", condition=condition, t=t, e=e, name=name)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py:558 _apply_op_helper
inferred_from[input_arg.type_attr]))
TypeError: Input 'e' of 'SelectV2' Op has type int64 that does not match type int32 of argument 't'.

我不明白这个错误是什么

正如错误所说,似乎变量't'应该具有'int32'的dtype,但您的数据样本类型为'int64',因此只需要通过使用tf.cast(..., int32)或通过设置变量't' dtype为int64将数据样本转换为'int32'。

相关内容

  • 没有找到相关文章

最新更新