model_name = "gpt2"
model = TFGPT2ForSequenceClassification.from_pretrained(model_name)
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
tokenizer.add_special_tokens({'pad_token': '[PAD]'})
When I am running the above code, the model is downloaded successfully.
Once the model is downloaded, I am defining the model configuration and loading the model with the updated configuration which throws an error 'OSError: Error no file named tf_model.h5 or pytorch_model.bin found in directory gpt2-medium.'
#Define model configuration
model_config = model.config
model_config.num_labels = 5
#Save model configuration
model_config.save_pretrained(model_name)
#Load model with updated configuration
model = TFGPT2ForSequenceClassification.from_pretrained(model_name, num_labels =5)
How can I resolve this issue?
Please check if the "pytorch_model.bin" or "tf_model.h5" file is available in your downloaded repo.
Or maybe the path isn't correct.