BERT NER Python

341 views Asked by At

I am using BERT model for Named Entity Recognition task. I have torch version - 1.2.0+cu9.2 torch vision version - 0.4.0+cu9.2 Nvidia drivers compatible with cuda 9.2

when i am trying to train my model using the command

loss, scores = model(b_input_ids.type(torch.cuda.LongTensor), token_type_ids=None,attention_mask=b_input_mask.to(device), labels=b_labels.type(torch.cuda.LongTensor))

i am getting the error below -

C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [35,0,0], thread: [0,0,0] Assertion `srcIndex < srcSelectDimSize` failed.

Can somebody help me with this one?

1

There are 1 answers

0
sophros On

A bit of googling provided the following hint with the following suggestions:

This is due to an out of bounds index in the embedding matrix.

If you are seeing this error using an nn.Embedding layer, you might add a print statement which shows the min and max values for each input. Some batches might have an out of bounds index. Once you find, the erroneous batch you should have a look how it was created so that you can fix this error.

Without seeing your code nobody is going to be able to help more.