TypeError: full_like() got an unexpected keyword argument 'shape'

I have finished training my BERT model from scratch after calling trainer.train()

Next, I want to evaluate my val set and get val loss by calling trainer.evaluate() but I have received this error TypeError: full_like() got an unexpected keyword argument 'shape'

I couldn’t find much information about this error or a solution to fix it. If anyone could give me a suggestion it would be highly appreciated.

Here is the full code of my Trainer and Training arguments:
from transformers import Trainer, TrainingArguments

training_args = TrainingArguments(
    output_dir="./bertmodel",
    overwrite_output_dir=True,
    num_train_epochs=5,
    per_device_train_batch_size=32,
    per_device_eval_batch_size=32,
    save_steps=10000,
    save_total_limit=2,
    do_train=True,                        
    do_eval=True, 
    logging_steps=700,
    eval_steps = None,
    prediction_loss_only=True,
)

trainer = Trainer(
    model=model,
    args=training_args,
    data_collator=data_collator,
    train_dataset=train_dataset,
    eval_dataset=eval_dataset,
)

Maybe you need upgrade package numpy by ‘pip install numpy --upgrade’

1 Like

Is this error related to numpy package version? Interesting - I will try that out. Thank you very much!

Oh it’s new-ish indeed. I made a PR to ensure we have numpy 1.17 minimum installed as a dependency to avoid this error in the future.

2 Likes

Thank you so much, now it makes sense why my code didn’t work previously!!