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
RuntimeError: Expected tensor for argument #1 'indices' to have one of the following scalar types: Long, Int; but got torch.cuda.FloatTensor instead (while checking arguments for embedding)
#15302
Closed
neeraj1909 opened this issue
Jan 23, 2022
· 2 comments
I am using Captum for interpreting the attributions of the tokens in each layer using Layer-Conductance lc = LayerConductance(predict, model.bert.encoder.layer[i])
Now, in the line layer_attributions = lc.attribute(inputs=input_ids, baselines=ref_input_ids, additional_forward_args=(attention_mask,))
RuntimeError is generating.
A helper function to perform forward pass of the model and make predictions. def predict(input_ids, attention_mask=None): outputs, attention_weights = model(input_ids=input_ids, attention_mask=attention_mask) preds = torch.softmax(outputs, dim = 1)[0][1].unsqueeze(0) return preds
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.
Environment info
transformers
version: 4.12.5Who can help
@LysandreJik @vanpelt @arfon
Information
I am using Captum for interpreting the attributions of the tokens in each layer using Layer-Conductance
lc = LayerConductance(predict, model.bert.encoder.layer[i])
Now, in the line
layer_attributions = lc.attribute(inputs=input_ids, baselines=ref_input_ids, additional_forward_args=(attention_mask,))
RuntimeError is generating.
A helper function to perform forward pass of the model and make predictions.
def predict(input_ids, attention_mask=None): outputs, attention_weights = model(input_ids=input_ids, attention_mask=attention_mask) preds = torch.softmax(outputs, dim = 1)[0][1].unsqueeze(0) return preds
Model I am using: "google/muril-base-cased"
#2952
Expected behavior
Code is working fine during training and prediction but raising errors while interpreting the layers with captum.
Any help would be greatly appreciated.
The text was updated successfully, but these errors were encountered: