The following is my program code. However, I received an error message as "Error Message". Could you show me how to solve this problem?
bex = BertExtractor()
df["text_feature"] = df["text"].progress_apply(lambda x: bex.extract(x))
sim = cos_sim_matrix(np.stack(df.text_feature))
Error Message
AttributeError: 'str' object has no attribute 'detach'
Explanation of Error Message
AttributeError Traceback (most recent call last)
<ipython-input-69-dff606d12a1d> in <module>()
17
18 bex = BertExtractor()
---> 19 df["text_feature"] = df["text"].progress_apply(lambda x: bex.extract(x))
20 sim = cos_sim_matrix(np.stack(df.text_feature))
21
pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()
<ipython-input-60-f7c4eb8ea2b1> in extract(self, sentence)
24 return seq_out[0][0].cpu().detach().numpy()
25 else:
---> 26 return seq_out[0][0].detach().numpy()
27
question from:
https://stackoverflow.com/questions/65661238/problem-on-dftext-progress-applylambda-x-bex-extractx 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…