Please help with TypeError: __init__() missing 1 required positional argument: 'tokenizer'

#71
by jinbo1129 - opened

hello, thanks for this great tool Geneformer !!!

I try to redo the examples from here for cell_classification.

However, I am new to hugging face and I met with a problem:

    # reload pretrained model
    model = BertForSequenceClassification.from_pretrained("/mypath/Geneformer/", 
                        num_labels=len(organ_label_dict.keys()),
                        output_attentions = False,
                        output_hidden_states = False)   ## I do not have any GPU resources, so I remove to("cuda")


    # create the trainer
    trainer = Trainer(
        model=model,
        args=training_args_init,
        data_collator=DataCollatorForCellClassification(),
        train_dataset=organ_trainset,
        eval_dataset=organ_evalset,
        compute_metrics=compute_metrics
    )

the error info:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[10], line 55
     49 training_args_init = TrainingArguments(**training_args)
     51 # create the trainer
     52 trainer = Trainer(
     53     model=model,
     54     args=training_args_init,
---> 55     data_collator=DataCollatorForCellClassification(),
     56     train_dataset=organ_trainset,
     57     eval_dataset=organ_evalset,
     58     compute_metrics=compute_metrics
     59 )
     60 # train the cell type classifier
     61 trainer.train()

TypeError: __init__() missing 1 required positional argument: 'tokenizer'

Could you help with this problem ? Thanks !!!
Is the above error caused by a lack of GPU resources on my system?

Thanks !!!

Thank you for your interest in Geneformer. This appears similar to closed issue #31. You may be using an outdated version. Please try to pull the current version (including notebooks and modules) and make sure your resources are not using the old version if it remains on your system. Let me know if that works or if it’s still an issue.

thanks for your help !!!
It works now !!!

jinbo1129 changed discussion status to closed

Sign up or log in to comment