"在HuggingFace官方[模型库](https://huggingface.co/models)上找到需要下载的模型,点击模型链接,例如:[xlnet-base-cased](https://huggingface.co/xlnet-base-cased)模型。在跳转到的模型页面中点击`List all files in model`(字比较小,注意查看),将跳出框中的模型相关文(pytorch或tf版本)件保存到本地。\n",
"print(\"Confirm that the gradients are computed for the original XLNet parameters.\\n\")\n",
"print(\"=\"*25)\n",
"for param in classifier.parameters():\n",
" print(param.shape, param.grad.sum() if not param.grad is None else param.grad)"
],
"execution_count": 11,
"outputs": [
{
"output_type": "stream",
"text": [
"/usr/local/lib/python3.6/dist-packages/transformers/modeling_xlnet.py:283: UserWarning: Mixed memory format inputs detected while calling the operator. The operator will output contiguous tensor even if some of the inputs are in channels_last format. (Triggered internally at /pytorch/aten/src/ATen/native/TensorIterator.cpp:918.)\n",
" attn_score = (ac + bd + ef) * self.scale\n"
],
"name": "stderr"
},
{
"output_type": "stream",
"text": [
"Loss: 3.1768088340759277\n",
"=========================\n",
"Confirm that the gradients are computed for the original XLNet parameters.\n",
" print(\"\\nTrue Start: {}, True End: {}\\nPred Start Prob: {}, Pred End Prob: {}\\nPred Max Start: {}, Pred Max End: {}\\nPred Max Start Prob: {}, Pred Max end Prob:{}\\nLoss: {}\\n\".format(\n",