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
import torch.nn.functional as f
texts='i dont know'
def predictor(texts):
token=tokenizer(texts, return_tensors="pt", padding=True).to(device)
print(token)
outputs = model(**token)
print(type(outputs))
probas = f.softmax(outputs.logits,dim=1).detach().cpu().numpy()
return probas
print(predictor(texts))
stringpreds='Parth is'
exp=explainer.explain_instance(stringpreds,predictor,num_samples=10)
**when ever i include more than a word in the stringpreds i get a value error, it works perfectly fine for a single word i do not know what happens when i increase the word am using a layoutLMfortokenclassification model **
this the error i get:
[/usr/local/lib/python3.10/dist-packages/lime/lime_base.py](https://localhost:8080/#) in feature_selection(self, data, labels, weights, num_features, method)
132 else:
133 n_method = 'highest_weights'
--> 134 return self.feature_selection(data, labels, weights,
135 num_features, n_method)
136
[/usr/local/lib/python3.10/dist-packages/lime/lime_base.py](https://localhost:8080/#) in feature_selection(self, data, labels, weights, num_features, method)
108 else:
109 weighted_data = coef * data[0]
--> 110 feature_weights = sorted(
111 zip(range(data.shape[1]), weighted_data),
112 key=lambda x: np.abs(x[1]),
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
The text was updated successfully, but these errors were encountered:
**when ever i include more than a word in the
stringpreds
i get a value error, it works perfectly fine for a single word i do not know what happens when i increase the word am using a layoutLMfortokenclassification model **this the error i get:
The text was updated successfully, but these errors were encountered: