Open renhao1998 opened 2 years ago
When i run the code follow README.md , if report error like this , can you explain what happened ? thanks a lot !
BERT_meets_Shapley/Code/TransSHAP_master/explainers/LIME_for_text.py in predict(self, data) 47 outputs = self.model(input_ids=tokens_tensor) 48 # logits = outputs[0] ---> 49 predictions = outputs.detach().cpu().numpy() 50 final = [self.softmax(x) for x in predictions] 51 return np.array(final)
AttributeError: 'BaseModelOutputWithPoolingAndCrossAttentions' object has no attribute 'detach'
I faced the same issue and the code runs when I change predictions = outputs.detach().cpu().numpy() to predictions = outputs.logits.detach().cpu().numpy()
predictions = outputs.detach().cpu().numpy()
predictions = outputs.logits.detach().cpu().numpy()
When i run the code follow README.md , if report error like this , can you explain what happened ? thanks a lot !
BERT_meets_Shapley/Code/TransSHAP_master/explainers/LIME_for_text.py in predict(self, data) 47 outputs = self.model(input_ids=tokens_tensor) 48 # logits = outputs[0] ---> 49 predictions = outputs.detach().cpu().numpy() 50 final = [self.softmax(x) for x in predictions] 51 return np.array(final)
AttributeError: 'BaseModelOutputWithPoolingAndCrossAttentions' object has no attribute 'detach'