_batch_encode_plus() получил неожиданный аргумент ключевого слова return_attention_masks.Python

Программы на Python
Ответить
Anonymous
 _batch_encode_plus() получил неожиданный аргумент ключевого слова return_attention_masks.

Сообщение Anonymous »

Я изучаю модель RoBERTA для обнаружения эмоций в твитах.
В совместной лаборатории Google. После этого файла Noteboook от Kaggle — https://www.kaggle.com/ishivinal/tweet- ... d=38608295
Фрагмент кода:
def regular_encode(texts, tokenizer, maxlen=512):
enc_di = tokenizer.batch_encode_plus(
texts,
return_attention_masks=True,
return_token_type_ids=False,
pad_to_max_length=True,
#padding=True,
max_length=maxlen
)

return np.array(enc_di['input_ids'])

def build_model(transformer, max_len=160):
input_word_ids = Input(shape=(max_len,), dtype=tf.int32, name="input_word_ids")
sequence_output = transformer(input_word_ids)[0]
cls_token = sequence_output[:, 0, :]
out = Dense(13, activation='softmax')(cls_token)

model = Model(inputs=input_word_ids, outputs=out)
model.compile(Adam(lr=1e-5), loss='categorical_crossentropy', metrics=['accuracy'])

return model

AUTO = tf.data.experimental.AUTOTUNE
MODEL = 'roberta-base'
tokenizer = AutoTokenizer.from_pretrained(MODEL)

X_train_t = regular_encode(X_train, tokenizer, maxlen= max_len)
X_test_t = regular_encode(X_test, tokenizer, maxlen=max_len)

В части Regular_encode я получаю следующую ошибку:
TypeError Traceback (most recent call last)
in ()
----> 1 X_train_t = regular_encode(X_train, tokenizer, maxlen= max_len)
2 X_test_t = regular_encode(X_test, tokenizer, maxlen=max_len)

2 frames
/usr/local/lib/python3.7/dist-packages/transformers/models/gpt2/tokenization_gpt2_fast.py in _batch_encode_plus(self, *args, **kwargs)
161 )
162
--> 163 return super()._batch_encode_plus(*args, **kwargs)
164
165 def _encode_plus(self, *args, **kwargs) -> BatchEncoding:

TypeError: _batch_encode_plus() got an unexpected keyword argument 'return_attention_masks'


Подробнее здесь: https://stackoverflow.com/questions/693 ... tion-masks
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»