在kaggle上复现别人代码。
model.save_pretrained( )报错:'transformer_model' object has no attribute 'save_pretrained'
使用了xlnet。先定义了class
class transformer_model(nn.Module):
def __init__(self, model_name, drop_prob = dropout_prob):
super(transformer_model, self).__init__()
configuration = XLNetConfig.from_pretrained(model_name, output_hidden_states=True)
self.xlnet = XLNetModel.from_pretrained(model_name, config = configuration)
......
然后定义model
model = transformer_model(model_name).to(device)
......
在执行下条语句报错
model.save_pretrained(bestpoint_dir)
print("Saving model bestpoint to ", bestpoint_dir)
报错内容:'transformer_model' object has no attribute 'save_pretrained'_
搜索了很久没有找到解决办法,请不吝赐教,非常感谢!!