bert_chinese_pytorch
bert_chinese_pytorch copied to clipboard
如何使用已训练好的output_dir下的model,而不是每次都do_train?
直接把do_train参数取消,提示: Output directory (path) already exists and is not empty.
用下面这行代码就可以读取模型了(前提是已经定义好model)
model.load_state_dict(torch.load(model_save_pth)['state_dict'])
理论上来说,只要用
model = BertForSequenceClassification.from_pretrained(args.bert_model, cache_dir=PYTORCH_PRETRAINED_BERT_CACHE / 'distributed_{}'.format(args.local_rank))
加载完模型后,跟个load就行
用下面这行代码就可以读取模型了(前提是已经定义好model)
model.load_state_dict(torch.load(model_save_pth)['state_dict'])
理论上来说,只要用
model = BertForSequenceClassification.from_pretrained(args.bert_model, cache_dir=PYTORCH_PRETRAINED_BERT_CACHE / 'distributed_{}'.format(args.local_rank))
加载完模型后,跟个load就行
明白了,不局限于给定的cmd参数运行。
@lxgend 请问你的预测网络是怎么写的哈