我阅读了官方教程(https://huggingface.co/transformers/model_doc/bert.html)并尝试设置配置,但它不起作用。
from transformers import PretrainedConfig
model = BertForSequenceClassification.from_pretrained("bert-base-uncased", num_labels=2)
model.config.output_hidden_states = True
model.load_state_dict(torch.load('../parameter.pkl'))
model.cuda()
output = model(input)发布于 2020-01-05 01:48:59
输出应该是包含隐藏状态的列表。我预计,因为您加载的parameter.pkl在默认情况下可能没有输出隐藏状态,所以它会将您的config.output_hidden_states覆盖为False?加载state_dict后,如果将其设置为True,会发生什么?
https://stackoverflow.com/questions/59592736
复制相似问题