{"id":3640,"date":"2020-11-14T15:42:37","date_gmt":"2020-11-14T07:42:37","guid":{"rendered":"http:\/\/www.sniper97.cn\/?p=3640"},"modified":"2020-11-14T15:42:37","modified_gmt":"2020-11-14T07:42:37","slug":"%e3%80%90transformers%e3%80%91tfbertforpretraining","status":"publish","type":"post","link":"http:\/\/www.sniper97.cn\/index.php\/note\/deep-learning\/transformers\/3640\/","title":{"rendered":"\u3010transformers\u3011TFBertForPreTraining"},"content":{"rendered":"\n<p>transformers\u7684TFBertForPreTraining<\/p>\n\n\n<p>\u8fd9\u4e2a\u7c7b\u6682\u65f6\u8fd8\u6ca1\u627e\u5230\u4ec0\u4e48\u53ef\u4ee5\u5e94\u7528\u7684\u5177\u4f53\u4efb\u52a1\uff0c\u5e94\u8be5\u5c5e\u4e8e\u4e00\u4e2a\u57fa\u7c7b\uff0c\u4e0b\u6e38\u4efb\u52a1\u8c03\u7528\u7684\uff0c\u7b49\u770b\u5230\u80fd\u7528\u7684\u4e0b\u6e38\u4efb\u52a1\u56de\u6765\u8865\u5168\u3002<\/p>\n\n\n<p>\u6682\u65f6\u770b\u4e00\u4e0b\u6e90\u7801\u3002<\/p>\n\n\n<p>\u8fd9\u4e2a\u5e93\u5e94\u8be5\u65f6Bert\u9884\u8bad\u7ec3\u7684\u6a21\u578b\uff0c\u4e0d\u540c\u4e8e<a href=\"http:\/\/www.sniper97.cn\/index.php\/note\/deep-learning\/transformers\/3629\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"TFBertModel\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\">TFBertModel<\/a>\uff0c\u8fd9\u4e2a\u6a21\u578b<strong>\u591a<\/strong>\u5e26\u4e86\u4e24\u4e2a\u7ed3\u6784\uff0c\u4e00\u4e2a\u7528\u4e8eNSP\uff08next sentence predict\uff09\u4efb\u52a1\uff0c\u53e6\u4e00\u4e2a\u7528\u4e8eMLM\uff08masked language model\uff09\u4efb\u52a1\u3002<\/p>\n\n\n<h2 class=\"wp-block-heading\">\nTFBertForPreTraining\n<\/h2>\n\n\n<p>\u4e0b\u9762\u8ba9\u6211\u4eec\u6765\u770b\u770bTFBertForPreTraining\u7684\u6e90\u7801\u3002<\/p>\n\n\n<h3 class=\"wp-block-heading\">\u6e90\u7801<\/h3>\n\n\n<p>\u9996\u5148\u6211\u4eec\u53ef\u4ee5\u770b\u5230init\u4e2d\u7684\u5b9a\u4e49<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"610\" height=\"150\" src=\"\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-10.png\" alt=\"\" class=\"wp-image-3641\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-10.png 610w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-10-300x74.png 300w\" sizes=\"(max-width: 610px) 100vw, 610px\" \/><\/figure><\/div>\n\n\n<p>\u5bf9\u6bd4<a href=\"http:\/\/www.sniper97.cn\/index.php\/note\/deep-learning\/transformers\/3629\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"TFBertModel\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\">TFBertModel<\/a>\u7684init\uff1a<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"433\" height=\"94\" src=\"\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-11.png\" alt=\"\" class=\"wp-image-3642\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-11.png 433w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-11-300x65.png 300w\" sizes=\"(max-width: 433px) 100vw, 433px\" \/><\/figure><\/div>\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u53ea\u662f\u591a\u4e86\u4e00\u4e2ansp\u548cmlm\u3002<\/p>\n\n\n<p>\u6211\u4eec\u518d\u770bcall\uff1a<\/p>\n\n\n<p>TFBertForPreTraining\u7684\uff08\u7531\u4e8ecall\u4e2d\u72b6\u6001\u5224\u65ad\u8f83\u591a\uff0c\u6bd4\u5982\u8fd4\u4e0d\u8fd4\u56deattention state\u7b49\uff0c\u56e0\u6b64\u53ea\u622a\u53d6\u90e8\u5206\uff0c\u8fd4\u56de\u7684\u53c2\u6570\u524d\u9762\u70b9\u4e86\u4e2a\u7ea2\u70b9\uff09\uff1a<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"537\" height=\"308\" src=\"\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-13.png\" alt=\"\" class=\"wp-image-3645\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-13.png 537w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-13-300x172.png 300w\" sizes=\"(max-width: 537px) 100vw, 537px\" \/><\/figure><\/div>\n\n\n<p>\u5bf9\u6bd4TFBertModel\uff1a<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"335\" height=\"44\" src=\"\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-14.png\" alt=\"\" class=\"wp-image-3646\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-14.png 335w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-14-300x39.png 300w\" sizes=\"(max-width: 335px) 100vw, 335px\" \/><\/figure><\/div>\n\n\n<p>\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u660e\u663e\u7684\u770b\u51fa\u6765\u5dee\u522b\uff1a<\/p>\n\n\n<p>TFBertForPreTraining\u76f8\u6bd4TFBertModel\uff0c<strong>\u591a\u4e86mlm\u548cnsp<\/strong>\uff0c\u5206\u522b\u5904\u7406\u7684\u662f\u9690\u85cf\u5c42\u72b6\u6001\u548cFC\u7684\u8f93\u51fa\uff08TFBertMainLayer\u7684\u8fd4\u56de\u8be6\u89c1<a rel=\"noreferrer noopener\" aria-label=\"TFBertModel\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\" href=\"http:\/\/www.sniper97.cn\/index.php\/note\/deep-learning\/transformers\/3629\/\" target=\"_blank\">TFBertModel<\/a>\uff09\u3002<\/p>\n\n\n<p>\u90a3\u4e48\u662f\u600e\u4e48\u5904\u7406\u7684\u5462\uff1f<\/p>\n\n\n<h4 class=\"wp-block-heading\">\u7ee7\u7eed\u67e5\u770bmlm\u7684\u6e90\u7801\uff1a<\/h4>\n\n\n<p>\u5148\u4e0d\u770bcall\uff0c\u53ea\u770binit<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"207\" src=\"\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-15.png\" alt=\"\" class=\"wp-image-3647\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-15.png 708w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-15-300x88.png 300w\" sizes=\"(max-width: 708px) 100vw, 708px\" \/><\/figure><\/div>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"457\" height=\"91\" src=\"\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-20.png\" alt=\"\" class=\"wp-image-3652\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-20.png 457w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-20-300x60.png 300w\" sizes=\"(max-width: 457px) 100vw, 457px\" \/><\/figure><\/div>\n\n\n<p> \u7ee7\u7eed\u770b \uff1a<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"611\" height=\"213\" src=\"\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-16.png\" alt=\"\" class=\"wp-image-3648\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-16.png 611w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-16-300x105.png 300w\" sizes=\"(max-width: 611px) 100vw, 611px\" \/><\/figure><\/div>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"553\" height=\"122\" src=\"\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-19.png\" alt=\"\" class=\"wp-image-3651\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-19.png 553w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-19-300x66.png 300w\" sizes=\"(max-width: 553px) 100vw, 553px\" \/><\/figure><\/div>\n\n\n<p>\u7ee7\u7eed\uff1a<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"818\" height=\"290\" src=\"\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-17.png\" alt=\"\" class=\"wp-image-3649\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-17.png 818w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-17-300x106.png 300w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-17-768x272.png 768w\" sizes=\"(max-width: 818px) 100vw, 818px\" \/><\/figure><\/div>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"432\" height=\"120\" src=\"\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-18.png\" alt=\"\" class=\"wp-image-3650\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-18.png 432w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-18-300x83.png 300w\" sizes=\"(max-width: 432px) 100vw, 432px\" \/><\/figure><\/div>\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0c\u5728\u8fd9\u91cc\u5c31\u53ea\u662f\u4e00\u4e2aDense+\u6fc0\u6d3b+LayerNorm\uff0c\u800ccall\u4e2d\u4e5f\u53ea\u662f\u7ebf\u6027\u7684\u8c03\u7528\u800c\u5df2\u3002<\/p>\n\n\n<p>\u800c\u4e0a\u4e00\u5c42TFBertLMpredictionHead\u7684call\u4e2d\uff0c\u8fd8\u6709\u4e00\u4e2ainput embedding\uff0c\u7ee7\u7eed\u518d\u4e0a\u4e00\u5c42\u7684call\u5c31\u4e5f\u662f\u4e2a\u7b80\u5355\u7684\u8c03\u7528\u3002<\/p>\n\n\n<h4 class=\"wp-block-heading\">\u7ee7\u7eed\u67e5\u770bnsp\u7684\u6e90\u7801\uff1a<\/h4>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"249\" src=\"\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-21.png\" alt=\"\" class=\"wp-image-3653\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-21.png 750w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/11\/\u56fe\u7247-21-300x100.png 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>\u5c31\u53ea\u662f\u4e00\u4e2adense\u5c42\uff0c\u6700\u540e\u8fd4\u56de2\u4e2a\u53c2\u6570\u3002<\/p>\n\n\n<h3 class=\"wp-block-heading\">\u6f14\u793a<\/h3>\n\n\n<p>\u7531\u4e8e\u53ea\u662f\u4e2a\u4e0a\u6e38\u4efb\u52a1\u6a21\u578b\uff0c\u6ca1\u6709\u627e\u5230\u4ec0\u4e48\u4e0b\u6e38\u4efb\u52a1\u548c\u6570\u636e\uff0c\u6682\u65f6\u4e0d\u505a\u6f14\u793a\uff0c\u53ea\u7ed9\u4e00\u4e2a\u5b98\u65b9demo\uff0c\u4ee5\u540e\u627e\u5230\u4efb\u52a1\u56de\u6765\u8865\u3002<\/p>\n\n\n<p>\u5b8c<a href=\"https:\/\/github.com\/Sniper970119\/ExampleForTransformers\/tree\/master\/TFBertForPreTraining\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"\u6574\u4ee3\u7801\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\">\u6574\u4ee3\u7801<\/a><\/p>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>transformers\u7684TFBertForPreTraining \u8fd9\u4e2a\u7c7b\u6682\u65f6\u8fd8\u6ca1\u627e\u5230\u4ec0\u4e48\u53ef\u4ee5\u5e94\u7528\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[25],"tags":[],"views":3043,"_links":{"self":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/3640"}],"collection":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/comments?post=3640"}],"version-history":[{"count":0,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/3640\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/media?parent=3640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/categories?post=3640"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/tags?post=3640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}