質問編集履歴

1

エラーをすべて表示しました。

2021/02/04 11:11

投稿

suisui_
suisui_

スコア0

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,51 @@
12
12
 
13
13
  ```
14
14
 
15
+ AttributeError Traceback (most recent call last)
16
+
15
- 'numpy.ndarray' object has no attribute 'sqrt'
17
+ AttributeError: 'numpy.ndarray' object has no attribute 'sqrt'
18
+
19
+
20
+
21
+ The above exception was the direct cause of the following exception:
22
+
23
+
24
+
25
+ TypeError Traceback (most recent call last)
26
+
27
+ <ipython-input-300-c18e50803453> in <module>
28
+
29
+ 33 for n in range(len(all_words_df_new)):
30
+
31
+ 34 cos_text = all_words_df_new.iloc[n]
32
+
33
+ ---> 35 cos = np.dot(words_df_new_float, cos_text) / (np.linalg.norm(words_df_new_float)* np.linalg.norm(cos_text))
34
+
35
+ 36 cos_sim.append(cos)
36
+
37
+ 37 all_words_df_new["cos_sim"] = cos_sim
38
+
39
+
40
+
41
+ <__array_function__ internals> in norm(*args, **kwargs)
42
+
43
+
44
+
45
+ ~\anaconda3\envs\watanabe\lib\site-packages\numpy\linalg\linalg.py in norm(x, ord, axis, keepdims)
46
+
47
+ 2475 else:
48
+
49
+ 2476 sqnorm = dot(x, x)
50
+
51
+ -> 2477 ret = sqrt(sqnorm)
52
+
53
+ 2478 if keepdims:
54
+
55
+ 2479 ret = ret.reshape(ndim*[1])
56
+
57
+
58
+
59
+ TypeError: loop of ufunc does not support argument 0 of type numpy.ndarray which has no callable sqrt method
16
60
 
17
61
  ```
18
62