我正在使用阿拉伯语 Bert 并批量传递我的训练数据集,我收到的错误消息是 Tensor 不能被视为 numpy 数组,但无法使用 detach().numpy() 分离到 numpy
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:571 train_function *
outputs = self.distribute_strategy.run(
<ipython-input-9-271b41658d5b>:46 call *
x = self.embed_with_bert(inputs)
<ipython-input-9-271b41658d5b>:39 embed_with_bert *
embds = self.bert_layer(all_tokens[:,0,:].detach().numpy(),
AttributeError: 'Tensor' object has no attribute 'detach'
Run Code Online (Sandbox Code Playgroud)
当我将标记生成器更改为“tf”时也是如此
我收到以下错误:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:571 train_function *
outputs = self.distribute_strategy.run(
<ipython-input-17-b2127b5212bc>:46 call *
x = self.embed_with_bert(inputs)
<ipython-input-53-b99c90611f94>:39 embed_with_bert *
embds = self.bert_layer([all_tokens[:,0,:],
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py:550 __call__ *
result = self.forward(*input, **kwargs)
/usr/local/lib/python3.6/dist-packages/transformers/modeling_bert.py:691 forward *
input_shape = input_ids.size()
AttributeError: 'list' object has no attribute 'size'
Run Code Online (Sandbox Code Playgroud)
也尝试过这个
embds = self.bert_layer(tf.unstack(all_tokens[:,0,:]),
tf.unstack(all_tokens[:,1,:]), …Run Code Online (Sandbox Code Playgroud)