質問編集履歴
3
誤字の修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
AttributeErrorのエラーを解決したい
|
test
CHANGED
File without changes
|
2
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,23 +8,23 @@
|
|
8
8
|
|
9
9
|
### 発生している問題・エラーメッセージ
|
10
10
|
|
11
|
-
|
11
|
+
---------------------------------------------------------------------------
|
12
12
|
|
13
|
-
|
13
|
+
AttributeError Traceback (most recent call last)
|
14
14
|
|
15
|
-
|
15
|
+
<ipython-input-8-e55b309388b6> in <module>()
|
16
16
|
|
17
|
-
|
17
|
+
1 small_train_dataset = 'tf_train_dataset'
|
18
18
|
|
19
|
-
|
19
|
+
2 small_eval_dataset = 'tf_eval_dataset'
|
20
20
|
|
21
|
-
|
21
|
+
----> 3 tf_train_dataset = small_train_dataset.remove_columns(["text"]).with_format("tensorflow")
|
22
22
|
|
23
|
-
|
23
|
+
4 tf_eval_dataset = small_eval_dataset.remove_columns(["text"]).with_format("tensorflow")
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
-
|
27
|
+
AttributeError: 'str' object has no attribute 'remove_columns'
|
28
28
|
|
29
29
|
|
30
30
|
|
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
```
|
34
34
|
|
35
|
-
|
35
|
+
AttributeError: 'str' object has no attribute 'remove_columns'
|
36
36
|
|
37
37
|
|
38
38
|
|
@@ -42,36 +42,20 @@
|
|
42
42
|
|
43
43
|
### 該当のソースコード
|
44
44
|
|
45
|
-
|
45
|
+
import tensorflow as tf
|
46
|
+
|
47
|
+
from transformers import TFAutoModelForSequenceClassification
|
46
48
|
|
47
49
|
|
48
50
|
|
49
|
-
|
51
|
+
model = TFAutoModelForSequenceClassification.from_pretrained("bert-base-cased", num_labels=2)
|
50
52
|
|
51
53
|
|
52
54
|
|
53
|
-
train_dataset = tf
|
55
|
+
small_train_dataset = 'tf_train_dataset'
|
54
56
|
|
55
|
-
|
57
|
+
small_eval_dataset = 'tf_eval_dataset'
|
56
58
|
|
57
|
-
|
59
|
+
tf_train_dataset = small_train_dataset.remove_columns(["text"]).with_format("tensorflow")
|
58
60
|
|
59
|
-
))
|
60
|
-
|
61
|
-
val_dataset =
|
61
|
+
tf_eval_dataset = small_eval_dataset.remove_columns(["text"]).with_format("tensorflow")
|
62
|
-
|
63
|
-
dict(val_encodings),
|
64
|
-
|
65
|
-
val_labels
|
66
|
-
|
67
|
-
))
|
68
|
-
|
69
|
-
test_dataset = tf.data.Dataset.from_tensor_slices((
|
70
|
-
|
71
|
-
dict(test_encodings),
|
72
|
-
|
73
|
-
test_labels
|
74
|
-
|
75
|
-
))
|
76
|
-
|
77
|
-
```Python
|
1
再び動かしたら上記のようになりました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,23 +10,21 @@
|
|
10
10
|
|
11
11
|
ValueError Traceback (most recent call last)
|
12
12
|
|
13
|
-
<ipython-input-
|
13
|
+
<ipython-input-73-4be1ad62ec27> in <module>()
|
14
14
|
|
15
|
-
|
15
|
+
4
|
16
16
|
|
17
|
-
|
17
|
+
5 train_dataset = tf.data.Dataset.from_tensor_slices((
|
18
18
|
|
19
|
-
---->
|
19
|
+
----> 6 dict(train_encodings),
|
20
20
|
|
21
|
-
|
21
|
+
7 train_labels
|
22
22
|
|
23
|
-
|
23
|
+
8 ))
|
24
24
|
|
25
25
|
|
26
26
|
|
27
27
|
ValueError: dictionary update sequence element #0 has length 1; 2 is required
|
28
|
-
|
29
|
-
|
30
28
|
|
31
29
|
|
32
30
|
|
@@ -76,10 +74,4 @@
|
|
76
74
|
|
77
75
|
))
|
78
76
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
77
|
```Python
|