You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
使用ERNIE模型,进行微调时,出现错误:
Traceback (most recent call last):
File "D:\1.地下空间数据获取\netBuild\ERNIE\train.py", line 95, in
logits = model(input_ids, token_type_ids)
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddlenlp\transformers\ernie\modeling.py", line 709, in forward
outputs = self.ernie(
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddlenlp\transformers\ernie\modeling.py", line 357, in forward
encoder_outputs = self.encoder(
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddlenlp\transformers\model_outputs.py", line 304, in _transformer_encoder_fwd
layer_outputs = mod(
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddlenlp\transformers\model_outputs.py", line 83, in _transformer_encoder_layer_fwd
attn_outputs = self.self_attn(src, src, src, src_mask, cache)
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddle\nn\layer\transformer.py", line 432, in forward
out = tensor.matmul(weights, v)
File "D:\app\python38\lib\site-packages\paddle\tensor\linalg.py", line 239, in matmul
return _C_ops.matmul(x, y, transpose_x, transpose_y)
ValueError: (InvalidArgument) Pointer C should not be null.
[Hint: C should not be null.] (at ..\paddle/phi/kernels/funcs/blas/blas_impl.h:1373)
微调代码为:
model = ErnieForTokenClassification.from_pretrained("ernie-1.0", num_classes=len(labelVocab))
step = 0
for epoch in range(50):
for idx, (input_ids, token_type_ids, length, labels) in enumerate(train_loader):
logits = model(input_ids, token_type_ids)
loss = paddle.mean(loss_fn(logits, labels))
loss.backward()
optimizer.step()
optimizer.clear_grad()
step += 1
print("epoch:%d - step:%d - loss: %f" % (epoch, step, loss))
evaluate(model, metric, dev_loader)
请提出你的问题
使用ERNIE模型,进行微调时,出现错误:
Traceback (most recent call last):
File "D:\1.地下空间数据获取\netBuild\ERNIE\train.py", line 95, in
logits = model(input_ids, token_type_ids)
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddlenlp\transformers\ernie\modeling.py", line 709, in forward
outputs = self.ernie(
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddlenlp\transformers\ernie\modeling.py", line 357, in forward
encoder_outputs = self.encoder(
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddlenlp\transformers\model_outputs.py", line 304, in _transformer_encoder_fwd
layer_outputs = mod(
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddlenlp\transformers\model_outputs.py", line 83, in _transformer_encoder_layer_fwd
attn_outputs = self.self_attn(src, src, src, src_mask, cache)
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddle\nn\layer\transformer.py", line 432, in forward
out = tensor.matmul(weights, v)
File "D:\app\python38\lib\site-packages\paddle\tensor\linalg.py", line 239, in matmul
return _C_ops.matmul(x, y, transpose_x, transpose_y)
ValueError: (InvalidArgument) Pointer C should not be null.
[Hint: C should not be null.] (at ..\paddle/phi/kernels/funcs/blas/blas_impl.h:1373)
微调代码为:
model = ErnieForTokenClassification.from_pretrained("ernie-1.0", num_classes=len(labelVocab))
step = 0
for epoch in range(50):
for idx, (input_ids, token_type_ids, length, labels) in enumerate(train_loader):
logits = model(input_ids, token_type_ids)
loss = paddle.mean(loss_fn(logits, labels))
loss.backward()
optimizer.step()
optimizer.clear_grad()
step += 1
print("epoch:%d - step:%d - loss: %f" % (epoch, step, loss))
evaluate(model, metric, dev_loader)
我之前用一套训练数据运行成功了,换了一套训练数据就报错了,昨天觉得是数据本身或者预处理不当导致出现问题,但今天是在预训练到第三轮才报的错,应该不是数据本身或者预处理的问题。没有什么解决思路,希望能给与解答,谢谢。
The text was updated successfully, but these errors were encountered: