import transformers
from datasets import load_dataset
import tensorflow as tf
tokenizer = transformers.AutoTokenizer.from_pretrained( roberta-base )
df = load_dataset( csv , data_files={ train : FinalDatasetTrain.csv , test : FinalDatasetTest.csv })
def tokenize_function(examples):
return tokenizer(examples["text"], truncation=True)
tokenized_datasets = df.map(tokenize_function, batched=True)
data_collator = transformers.DataCollatorWithPadding(tokenizer=tokenizer)
model = transformers.AutoModelForSequenceClassification.from_pretrained( roberta-base , num_labels=7)
training_args = transformers.TFTrainingArguments(
output_dir="./results",
num_train_epochs=2,
per_device_train_batch_size=8,
per_device_eval_batch_size=16,
save_strategy= epoch ,
evaluation_strategy="epoch",
logging_dir="./logs",
)
trainer = transformers.Trainer(
model=model,
args=training_args,
train_dataset=tokenized_datasets[ train ],
eval_dataset=tokenized_datasets[ test ],
data_collator=data_collator,
tokenizer=tokenizer
)
trainer.train()
When I run this code I get an error saying:
AttributeError: AcceleratorState object has no attribute distributed_type .
How do I fix this (I tried both Jupyter notebook and Google Colab)?