Я изучаю модель 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
_batch_encode_plus() получил неожиданный аргумент ключевого слова return_attention_masks. ⇐ Python
Программы на Python
1731751325
Anonymous
Я изучаю модель RoBERTA для обнаружения эмоций в твитах.
В совместной лаборатории Google. После этого файла Noteboook от Kaggle — https://www.kaggle.com/ishivinal/tweet-emotions-anaлиз-using-lstm-glove-roberta?scriptVersionId=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'
Подробнее здесь: [url]https://stackoverflow.com/questions/69373420/batch-encode-plus-got-an-unexpected-keyword-argument-return-attention-masks[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия