{"id":19557,"date":"2024-03-14T14:21:12","date_gmt":"2024-03-14T06:21:12","guid":{"rendered":"https:\/\/aif.amtbbs.org\/?p=19557"},"modified":"2024-03-14T14:27:12","modified_gmt":"2024-03-14T06:27:12","slug":"%e8%b6%85%e5%bc%ba%ef%bc%81%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0top10%e7%ae%97%e6%b3%95%ef%bc%81","status":"publish","type":"post","link":"https:\/\/aif.amtbbs.org\/index.php\/2024\/03\/14\/19557\/","title":{"rendered":"\u8d85\u5f3a\uff01\u6df1\u5ea6\u5b66\u4e60Top10\u7b97\u6cd5\uff01"},"content":{"rendered":"<div class=\"article-desc\">\u81ea2006\u5e74\u6df1\u5ea6\u5b66\u4e60\u6982\u5ff5\u88ab\u63d0\u51fa\u4ee5\u6765\uff0c20\u5e74\u5feb\u8fc7\u53bb\u4e86\uff0c\u6df1\u5ea6\u5b66\u4e60\u4f5c\u4e3a\u4eba\u5de5\u667a\u80fd\u9886\u57df\u7684\u4e00\u573a\u9769\u547d\uff0c\u5df2\u7ecf\u50ac\u751f\u4e86\u8bb8\u591a\u5177\u6709\u5f71\u54cd\u529b\u7684\u7b97\u6cd5\u3002\u90a3\u4e48\uff0c\u4f60\u6240\u8ba4\u4e3a\u6df1\u5ea6\u5b66\u4e60\u7684top10\u7b97\u6cd5\u6709\u54ea\u4e9b\u5462\uff1f<\/div>\n<div id=\"postspictures\" class=\"article-content\">\n<div id=\"container\" class=\"container am-engine\" data-v-1d7a5742=\"\" data-element=\"root\">\n<p>\u81ea2006\u5e74\u6df1\u5ea6\u5b66\u4e60\u6982\u5ff5\u88ab\u63d0\u51fa\u4ee5\u6765\uff0c20\u5e74\u5feb\u8fc7\u53bb\u4e86\uff0c\u6df1\u5ea6\u5b66\u4e60\u4f5c\u4e3a\u4eba\u5de5\u667a\u80fd\u9886\u57df\u7684\u4e00\u573a\u9769\u547d\uff0c\u5df2\u7ecf\u50ac\u751f\u4e86\u8bb8\u591a\u5177\u6709\u5f71\u54cd\u529b\u7684\u7b97\u6cd5\u3002\u90a3\u4e48\uff0c\u4f60\u6240\u8ba4\u4e3a\u6df1\u5ea6\u5b66\u4e60\u7684top10\u7b97\u6cd5\u6709\u54ea\u4e9b\u5462\uff1f<\/p>\n<p><img data-dominant-color=\"8aabc2\" data-has-transparency=\"false\" style=\"--dominant-color: #8aabc2;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent alignnone size-full wp-image-19571\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/c7f841a00fda69425710326b69f7f49762fc82-1.jpg\" width=\"1280\" height=\"853\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/c7f841a00fda69425710326b69f7f49762fc82-1.jpg 1280w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/c7f841a00fda69425710326b69f7f49762fc82-1-300x200.jpg 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/c7f841a00fda69425710326b69f7f49762fc82-1-1024x682.jpg 1024w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/c7f841a00fda69425710326b69f7f49762fc82-1-150x100.jpg 150w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/c7f841a00fda69425710326b69f7f49762fc82-1-768x512.jpg 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p>\u4ee5\u4e0b\u662f\u82b1\u54e5\u6211\u5fc3\u76ee\u4e2d\u7684\u6df1\u5ea6\u5b66\u4e60top10\u7b97\u6cd5\uff0c\u5b83\u4eec\u5728\u521b\u65b0\u6027\u3001\u5e94\u7528\u4ef7\u503c\u548c\u5f71\u54cd\u529b\u65b9\u9762\u90fd\u5177\u6709\u91cd\u8981\u7684\u5730\u4f4d\u3002<\/p>\n<h4>1\u3001\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\uff08DNN\uff09<\/h4>\n<p>\u80cc\u666f\uff1a\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\uff08DNN\uff09\u4e5f\u53eb\u591a\u5c42\u611f\u77e5\u673a\uff0c\u662f\u6700\u666e\u904d\u7684\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\uff0c\u53d1\u660e\u4e4b\u521d\u7531\u4e8e\u7b97\u529b\u74f6\u9888\u800c\u9971\u53d7\u8d28\u7591\uff0c\u76f4\u5230\u8fd1\u4e9b\u5e74\u7b97\u529b\u3001\u6570\u636e\u7684\u7206\u53d1\u624d\u8fce\u6765\u7a81\u7834\u3002<\/p>\n<p><img data-dominant-color=\"eceded\" data-has-transparency=\"false\" style=\"--dominant-color: #eceded;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent alignnone size-full wp-image-19572\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/93881f691c983c0ff8707128f220b06ccca782-1.png\" width=\"801\" height=\"576\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/93881f691c983c0ff8707128f220b06ccca782-1.png 801w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/93881f691c983c0ff8707128f220b06ccca782-1-300x216.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/93881f691c983c0ff8707128f220b06ccca782-1-150x108.png 150w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/93881f691c983c0ff8707128f220b06ccca782-1-768x552.png 768w\" sizes=\"auto, (max-width: 801px) 100vw, 801px\" \/><\/p>\n<p>\u6a21\u578b\u539f\u7406\uff1a\u5b83\u662f\u4e00\u79cd\u5305\u542b\u591a\u4e2a\u9690\u85cf\u5c42\u7684\u795e\u7ecf\u7f51\u7edc\u3002\u6bcf\u4e00\u5c42\u90fd\u5c06\u5176\u8f93\u5165\u4f20\u9012\u7ed9\u4e0b\u4e00\u5c42\uff0c\u5e76\u4f7f\u7528\u975e\u7ebf\u6027\u6fc0\u6d3b\u51fd\u6570\u6765\u5f15\u5165\u5b66\u4e60\u7684\u975e\u7ebf\u6027\u7279\u6027\u3002\u901a\u8fc7\u7ec4\u5408\u8fd9\u4e9b\u975e\u7ebf\u6027\u53d8\u6362\uff0cDNN\u80fd\u591f\u5b66\u4e60\u8f93\u5165\u6570\u636e\u7684\u590d\u6742\u7279\u5f81\u8868\u793a\u3002<\/p>\n<p>\u6a21\u578b\u8bad\u7ec3\uff1a\u4f7f\u7528\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\u548c\u68af\u5ea6\u4e0b\u964d\u4f18\u5316\u7b97\u6cd5\u6765\u66f4\u65b0\u6743\u91cd\u3002\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u901a\u8fc7\u8ba1\u7b97\u635f\u5931\u51fd\u6570\u5173\u4e8e\u6743\u91cd\u7684\u68af\u5ea6\uff0c\u7136\u540e\u4f7f\u7528\u68af\u5ea6\u4e0b\u964d\u6216\u5176\u4ed6\u4f18\u5316\u7b97\u6cd5\u6765\u66f4\u65b0\u6743\u91cd\uff0c\u4ee5\u6700\u5c0f\u5316\u635f\u5931\u51fd\u6570\u3002<\/p>\n<p>\u4f18\u70b9\uff1a\u80fd\u591f\u5b66\u4e60\u8f93\u5165\u6570\u636e\u7684\u590d\u6742\u7279\u5f81\uff0c\u5e76\u6355\u83b7\u975e\u7ebf\u6027\u5173\u7cfb\u3002\u5177\u6709\u5f3a\u5927\u7684\u7279\u5f81\u5b66\u4e60\u548c\u8868\u793a\u80fd\u529b\u3002<\/p>\n<p>\u7f3a\u70b9\uff1a\u968f\u7740\u7f51\u7edc\u6df1\u5ea6\u7684\u589e\u52a0\uff0c\u68af\u5ea6\u6d88\u5931\u95ee\u9898\u53d8\u5f97\u4e25\u91cd\uff0c\u5bfc\u81f4\u8bad\u7ec3\u4e0d\u7a33\u5b9a\u3002\u5bb9\u6613\u9677\u5165\u5c40\u90e8\u6700\u5c0f\u503c\uff0c\u53ef\u80fd\u9700\u8981\u590d\u6742\u7684\u521d\u59cb\u5316\u7b56\u7565\u548c\u6b63\u5219\u5316\u6280\u672f\u3002<\/p>\n<p>\u4f7f\u7528\u573a\u666f\uff1a\u56fe\u50cf\u5206\u7c7b\u3001\u8bed\u97f3\u8bc6\u522b\u3001\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3001\u63a8\u8350\u7cfb\u7edf\u7b49\u3002<\/p>\n<p>Python\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\">\n<p><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_0\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">import numpy as np\r\nfrom keras.models import Sequential\r\nfrom keras.layers import Dense\r\n# \u5047\u8bbe\u670910\u4e2a\u8f93\u5165\u7279\u5f81\u548c3\u4e2a\u8f93\u51fa\u7c7b\u522b  \r\ninput_dim = 10\r\nnum_classes = 3\r\n# \u521b\u5efaDNN\u6a21\u578b  \r\nmodel = Sequential()\r\nmodel.add(Dense(64, activatinotallow='relu', input_shape=(input_dim,)))\r\nmodel.add(Dense(32, activatinotallow='relu'))\r\nmodel.add(Dense(num_classes, activatinotallow='softmax'))\r\n# \u7f16\u8bd1\u6a21\u578b\uff0c\u9009\u62e9\u4f18\u5316\u5668\u548c\u635f\u5931\u51fd\u6570  \r\nmodel.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])\r\n# \u5047\u8bbe\u6709100\u4e2a\u6837\u672c\u7684\u8bad\u7ec3\u6570\u636e\u548c\u6807\u7b7e  \r\nX_train = np.random.rand(100, input_dim)\r\ny_train = np.random.randint(0, 2, size=(100, num_classes))\r\n# \u8bad\u7ec3\u6a21\u578b  \r\nmodel.fit(X_train, y_train, epochs=10)<\/code><\/pre>\n<ul id=\"code_id_0\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h4>2\u3001\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09<\/h4>\n<p>\u6a21\u578b\u539f\u7406\uff1a\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09\u662f\u4e00\u79cd\u4e13\u95e8\u4e3a\u5904\u7406\u56fe\u50cf\u6570\u636e\u800c\u8bbe\u8ba1\u7684\u795e\u7ecf\u7f51\u7edc\uff0c\u7531Lechun\u5927\u4f6c\u8bbe\u8ba1\u7684Lenet\u662fCNN\u7684\u5f00\u5c71\u4e4b\u4f5c\u3002CNN\u901a\u8fc7\u4f7f\u7528\u5377\u79ef\u5c42\u6765\u6355\u83b7\u5c40\u90e8\u7279\u5f81\uff0c\u5e76\u901a\u8fc7\u6c60\u5316\u5c42\u6765\u964d\u4f4e\u6570\u636e\u7684\u7ef4\u5ea6\u3002\u5377\u79ef\u5c42\u5bf9\u8f93\u5165\u6570\u636e\u8fdb\u884c\u5c40\u90e8\u5377\u79ef\u64cd\u4f5c\uff0c\u5e76\u4f7f\u7528\u53c2\u6570\u5171\u4eab\u673a\u5236\u6765\u51cf\u5c11\u6a21\u578b\u7684\u53c2\u6570\u6570\u91cf\u3002\u6c60\u5316\u5c42\u5219\u5bf9\u5377\u79ef\u5c42\u7684\u8f93\u51fa\u8fdb\u884c\u4e0b\u91c7\u6837\uff0c\u4ee5\u964d\u4f4e\u6570\u636e\u7684\u7ef4\u5ea6\u548c\u8ba1\u7b97\u590d\u6742\u5ea6\u3002\u8fd9\u79cd\u7ed3\u6784\u7279\u522b\u9002\u5408\u5904\u7406\u56fe\u50cf\u6570\u636e\u3002<\/p>\n<p><img data-dominant-color=\"e5e9ef\" data-has-transparency=\"false\" style=\"--dominant-color: #e5e9ef;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent alignnone size-full wp-image-19573\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/369574e99198bbfea3b221a2a4c3563e8d9124-1.png\" width=\"1080\" height=\"701\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/369574e99198bbfea3b221a2a4c3563e8d9124-1.png 1080w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/369574e99198bbfea3b221a2a4c3563e8d9124-1-300x195.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/369574e99198bbfea3b221a2a4c3563e8d9124-1-1024x665.png 1024w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/369574e99198bbfea3b221a2a4c3563e8d9124-1-150x97.png 150w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/369574e99198bbfea3b221a2a4c3563e8d9124-1-768x498.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<p>\u6a21\u578b\u8bad\u7ec3\uff1a\u4f7f\u7528\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\u548c\u68af\u5ea6\u4e0b\u964d\u4f18\u5316\u7b97\u6cd5\u6765\u66f4\u65b0\u6743\u91cd\u3002\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u901a\u8fc7\u8ba1\u7b97\u635f\u5931\u51fd\u6570\u5173\u4e8e\u6743\u91cd\u7684\u68af\u5ea6\uff0c\u7136\u540e\u4f7f\u7528\u68af\u5ea6\u4e0b\u964d\u6216\u5176\u4ed6\u4f18\u5316\u7b97\u6cd5\u6765\u66f4\u65b0\u6743\u91cd\uff0c\u4ee5\u6700\u5c0f\u5316\u635f\u5931\u51fd\u6570\u3002<\/p>\n<p>\u4f18\u70b9\uff1a\u80fd\u591f\u6709\u6548\u5730\u5904\u7406\u56fe\u50cf\u6570\u636e\uff0c\u5e76\u6355\u83b7\u5c40\u90e8\u7279\u5f81\u3002\u5177\u6709\u8f83\u5c11\u7684\u53c2\u6570\u6570\u91cf\uff0c\u964d\u4f4e\u4e86\u8fc7\u62df\u5408\u7684\u98ce\u9669\u3002<\/p>\n<p>\u7f3a\u70b9\uff1a\u5bf9\u4e8e\u5e8f\u5217\u6570\u636e\u6216\u957f\u8ddd\u79bb\u4f9d\u8d56\u5173\u7cfb\u53ef\u80fd\u4e0d\u592a\u9002\u7528\u3002\u53ef\u80fd\u9700\u8981\u5bf9\u8f93\u5165\u6570\u636e\u8fdb\u884c\u590d\u6742\u7684\u9884\u5904\u7406\u3002<\/p>\n<p>\u4f7f\u7528\u573a\u666f\uff1a\u56fe\u50cf\u5206\u7c7b\u3001\u76ee\u6807\u68c0\u6d4b\u3001\u8bed\u4e49\u5206\u5272\u7b49\u3002<\/p>\n<p>Python\u793a\u4f8b\u4ee3\u7801<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\">\n<p><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_1\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">from keras.models import Sequential\r\nfrom keras.layers import Conv2D, MaxPooling2D, Flatten, Dense\r\n# \u5047\u8bbe\u8f93\u5165\u56fe\u50cf\u7684\u5f62\u72b6\u662f64x64\u50cf\u7d20\uff0c\u67093\u4e2a\u989c\u8272\u901a\u9053  \r\ninput_shape = (64, 64, 3)\r\n# \u521b\u5efaCNN\u6a21\u578b  \r\nmodel = Sequential()\r\nmodel.add(Conv2D(32, (3, 3), activatinotallow='relu', input_shape=input_shape))\r\nmodel.add(MaxPooling2D((2, 2)))\r\nmodel.add(Conv2D(64, (3, 3), activatinotallow='relu'))\r\nmodel.add(Flatten())\r\nmodel.add(Dense(128, activatinotallow='relu'))\r\nmodel.add(Dense(num_classes, activatinotallow='softmax'))\r\n# \u7f16\u8bd1\u6a21\u578b\uff0c\u9009\u62e9\u4f18\u5316\u5668\u548c\u635f\u5931\u51fd\u6570  \r\nmodel.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])\r\n# \u5047\u8bbe\u6709100\u4e2a\u6837\u672c\u7684\u8bad\u7ec3\u6570\u636e\u548c\u6807\u7b7e  \r\nX_train = np.random.rand(100, *input_shape)\r\ny_train = np.random.randint(0, 2, size=(100, num_classes))\r\n# \u8bad\u7ec3\u6a21\u578b  \r\nmodel.fit(X_train, y_train, epochs=10)<\/code><\/pre>\n<ul id=\"code_id_1\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h4>3\u3001\u6b8b\u5dee\u7f51\u7edc\uff08ResNet\uff09<\/h4>\n<p>\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u7684\u5feb\u901f\u53d1\u5c55\uff0c\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u5728\u591a\u4e2a\u9886\u57df\u53d6\u5f97\u4e86\u663e\u8457\u7684\u6210\u529f\u3002\u7136\u800c\uff0c\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u7684\u8bad\u7ec3\u9762\u4e34\u7740\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u7b49\u95ee\u9898\uff0c\u8fd9\u9650\u5236\u4e86\u7f51\u7edc\u7684\u6df1\u5ea6\u548c\u6027\u80fd\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0c\u6b8b\u5dee\u7f51\u7edc\uff08ResNet\uff09\u88ab\u63d0\u51fa\u3002<\/p>\n<p><img data-dominant-color=\"e9e8e8\" data-has-transparency=\"false\" style=\"--dominant-color: #e9e8e8;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent alignnone size-full wp-image-19574\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/756b31a49a0c00e5c7c479c927c3616f38588c-1.png\" width=\"474\" height=\"296\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/756b31a49a0c00e5c7c479c927c3616f38588c-1.png 474w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/756b31a49a0c00e5c7c479c927c3616f38588c-1-300x187.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/756b31a49a0c00e5c7c479c927c3616f38588c-1-150x94.png 150w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/p>\n<p>\u6a21\u578b\u539f\u7406\uff1a<\/p>\n<p>ResNet\u901a\u8fc7\u5f15\u5165\u201c\u6b8b\u5dee\u5757\u201d\u6765\u89e3\u51b3\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u4e2d\u7684\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u95ee\u9898\u3002\u6b8b\u5dee\u5757\u7531\u4e00\u4e2a\u201c\u8df3\u8dc3\u8fde\u63a5\u201d\u548c\u4e00\u4e2a\u6216\u591a\u4e2a\u975e\u7ebf\u6027\u5c42\u7ec4\u6210\uff0c\u4f7f\u5f97\u68af\u5ea6\u53ef\u4ee5\u76f4\u63a5\u4ece\u540e\u9762\u7684\u5c42\u53cd\u5411\u4f20\u64ad\u5230\u524d\u9762\u7684\u5c42\uff0c\u4ece\u800c\u66f4\u597d\u5730\u8bad\u7ec3\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0cResNet\u80fd\u591f\u6784\u5efa\u975e\u5e38\u6df1\u7684\u7f51\u7edc\u7ed3\u6784\uff0c\u5e76\u5728\u591a\u4e2a\u4efb\u52a1\u4e0a\u53d6\u5f97\u4e86\u4f18\u5f02\u7684\u6027\u80fd\u3002<\/p>\n<p>\u6a21\u578b\u8bad\u7ec3\uff1a<\/p>\n<p>ResNet\u7684\u8bad\u7ec3\u901a\u5e38\u4f7f\u7528\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\u548c\u4f18\u5316\u7b97\u6cd5\uff08\u5982\u968f\u673a\u68af\u5ea6\u4e0b\u964d\uff09\u3002\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u901a\u8fc7\u8ba1\u7b97\u635f\u5931\u51fd\u6570\u5173\u4e8e\u6743\u91cd\u7684\u68af\u5ea6\uff0c\u5e76\u4f7f\u7528\u4f18\u5316\u7b97\u6cd5\u66f4\u65b0\u6743\u91cd\uff0c\u4ee5\u6700\u5c0f\u5316\u635f\u5931\u51fd\u6570\u3002\u6b64\u5916\uff0c\u4e3a\u4e86\u52a0\u901f\u8bad\u7ec3\u8fc7\u7a0b\u548c\u63d0\u9ad8\u6a21\u578b\u7684\u6cdb\u5316\u80fd\u529b\uff0c\u8fd8\u53ef\u4ee5\u91c7\u7528\u6b63\u5219\u5316\u6280\u672f\u3001\u96c6\u6210\u5b66\u4e60\u7b49\u65b9\u6cd5\u3002<\/p>\n<p>\u4f18\u70b9\uff1a<\/p>\n<ol class=\"list-paddingleft-1\" data-id=\"odd3d8fc-JRUHFQFN\">\n<li data-id=\"ld70c578-YVKYdK6A\">\u89e3\u51b3\u4e86\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u95ee\u9898\uff1a\u901a\u8fc7\u5f15\u5165\u6b8b\u5dee\u5757\u548c\u8df3\u8dc3\u8fde\u63a5\uff0cResNet\u80fd\u591f\u66f4\u597d\u5730\u8bad\u7ec3\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\uff0c\u907f\u514d\u4e86\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u7684\u95ee\u9898\u3002<\/li>\n<li data-id=\"ld70c578-3iMnP61m\">\u6784\u5efa\u4e86\u975e\u5e38\u6df1\u7684\u7f51\u7edc\u7ed3\u6784\uff1a\u7531\u4e8e\u89e3\u51b3\u4e86\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u95ee\u9898\uff0cResNet\u80fd\u591f\u6784\u5efa\u975e\u5e38\u6df1\u7684\u7f51\u7edc\u7ed3\u6784\uff0c\u4ece\u800c\u63d0\u9ad8\u4e86\u6a21\u578b\u7684\u6027\u80fd\u3002<\/li>\n<li data-id=\"ld70c578-lbcmZDQY\">\u5728\u591a\u4e2a\u4efb\u52a1\u4e0a\u53d6\u5f97\u4e86\u4f18\u5f02\u7684\u6027\u80fd\uff1a\u7531\u4e8e\u5176\u5f3a\u5927\u7684\u7279\u5f81\u5b66\u4e60\u548c\u8868\u793a\u80fd\u529b\uff0cResNet\u5728\u591a\u4e2a\u4efb\u52a1\u4e0a\u53d6\u5f97\u4e86\u4f18\u5f02\u7684\u6027\u80fd\uff0c\u5982\u56fe\u50cf\u5206\u7c7b\u3001\u76ee\u6807\u68c0\u6d4b\u7b49\u3002<\/li>\n<\/ol>\n<p>\u7f3a\u70b9\uff1a<\/p>\n<ol class=\"list-paddingleft-1\" data-id=\"odd3d8fc-b79jaaAi\">\n<li data-id=\"ld70c578-C6YLmFYI\">\u8ba1\u7b97\u91cf\u5927\uff1a\u7531\u4e8eResNet\u901a\u5e38\u6784\u5efa\u975e\u5e38\u6df1\u7684\u7f51\u7edc\u7ed3\u6784\uff0c\u56e0\u6b64\u8ba1\u7b97\u91cf\u8f83\u5927\uff0c\u9700\u8981\u8f83\u9ad8\u7684\u8ba1\u7b97\u8d44\u6e90\u548c\u65f6\u95f4\u8fdb\u884c\u8bad\u7ec3\u3002<\/li>\n<li data-id=\"ld70c578-0GDVZWeg\">\u53c2\u6570\u8c03\u4f18\u96be\u5ea6\u5927\uff1aResNet\u7684\u53c2\u6570\u6570\u91cf\u4f17\u591a\uff0c\u9700\u8981\u82b1\u8d39\u5927\u91cf\u65f6\u95f4\u548c\u7cbe\u529b\u8fdb\u884c\u8c03\u4f18\u548c\u8d85\u53c2\u6570\u9009\u62e9\u3002<\/li>\n<li data-id=\"ld70c578-AQcJpcc6\">\u5bf9\u521d\u59cb\u5316\u6743\u91cd\u654f\u611f\uff1aResNet\u5bf9\u521d\u59cb\u5316\u6743\u91cd\u7684\u9009\u62e9\u654f\u611f\u5ea6\u9ad8\uff0c\u5982\u679c\u521d\u59cb\u5316\u6743\u91cd\u4e0d\u5408\u9002\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u8bad\u7ec3\u4e0d\u7a33\u5b9a\u6216\u8fc7\u62df\u5408\u95ee\u9898\u3002<\/li>\n<\/ol>\n<p>\u4f7f\u7528\u573a\u666f\uff1a<\/p>\n<p>ResNet\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u573a\u666f\uff0c\u5982\u56fe\u50cf\u5206\u7c7b\u3001\u76ee\u6807\u68c0\u6d4b\u3001\u4eba\u8138\u8bc6\u522b\u7b49\u3002\u6b64\u5916\uff0cResNet\u8fd8\u53ef\u4ee5\u7528\u4e8e\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3001\u8bed\u97f3\u8bc6\u522b\u7b49\u9886\u57df\u3002<\/p>\n<p>Python\u793a\u4f8b\u4ee3\u7801\uff08\u7b80\u5316\u7248\uff09\uff1a<\/p>\n<p>\u5728\u8fd9\u4e2a\u7b80\u5316\u7248\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u6f14\u793a\u5982\u4f55\u4f7f\u7528Keras\u5e93\u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684ResNet\u6a21\u578b\u3002<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\">\n<p><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_2\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">from keras.models import Sequential\r\nfrom keras.layers import Conv2D, Add, Activation, BatchNormalization, Shortcut\r\ndef residual_block(input, filters):\r\nx = Conv2D(filters=filters, kernel_size=(3, 3), padding='same')(input)\r\nx = BatchNormalization()(x)\r\nx = Activation('relu')(x)\r\nx = Conv2D(filters=filters, kernel_size=(3, 3), padding='same')(x)\r\nx = BatchNormalization()(x)\r\nx = Activation('relu')(x)\r\nreturn x<\/code><\/pre>\n<ul id=\"code_id_2\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h4>4\u3001LSTM\uff08\u957f\u77ed\u65f6\u8bb0\u5fc6\u7f51\u7edc\uff09<\/h4>\n<p>\u5728\u5904\u7406\u5e8f\u5217\u6570\u636e\u65f6\uff0c\u4f20\u7edf\u7684\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff08RNN\uff09\u9762\u4e34\u7740\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u7b49\u95ee\u9898\uff0c\u8fd9\u9650\u5236\u4e86\u7f51\u7edc\u7684\u6df1\u5ea6\u548c\u6027\u80fd\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0cLSTM\u88ab\u63d0\u51fa\u3002<\/p>\n<p><img data-dominant-color=\"626c5c\" data-has-transparency=\"true\" style=\"--dominant-color: #626c5c;\" loading=\"lazy\" decoding=\"async\" class=\"has-transparency alignnone size-full wp-image-19575\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/05de7f943ef1ae11e422230e66cfe5d0611e9f-1.png\" width=\"1080\" height=\"404\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/05de7f943ef1ae11e422230e66cfe5d0611e9f-1.png 1080w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/05de7f943ef1ae11e422230e66cfe5d0611e9f-1-300x112.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/05de7f943ef1ae11e422230e66cfe5d0611e9f-1-1024x383.png 1024w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/05de7f943ef1ae11e422230e66cfe5d0611e9f-1-150x56.png 150w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/05de7f943ef1ae11e422230e66cfe5d0611e9f-1-768x287.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<p>\u6a21\u578b\u539f\u7406\uff1a<\/p>\n<p>LSTM\u901a\u8fc7\u5f15\u5165\u201c\u95e8\u63a7\u201d\u673a\u5236\u6765\u63a7\u5236\u4fe1\u606f\u7684\u6d41\u52a8\uff0c\u4ece\u800c\u89e3\u51b3\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u95ee\u9898\u3002LSTM\u6709\u4e09\u4e2a\u95e8\u63a7\u673a\u5236\uff1a\u8f93\u5165\u95e8\u3001\u9057\u5fd8\u95e8\u548c\u8f93\u51fa\u95e8\u3002\u8f93\u5165\u95e8\u51b3\u5b9a\u4e86\u65b0\u4fe1\u606f\u7684\u8fdb\u5165\uff0c\u9057\u5fd8\u95e8\u51b3\u5b9a\u4e86\u65e7\u4fe1\u606f\u7684\u9057\u5fd8\uff0c\u8f93\u51fa\u95e8\u51b3\u5b9a\u6700\u7ec8\u8f93\u51fa\u7684\u4fe1\u606f\u3002\u901a\u8fc7\u8fd9\u4e9b\u95e8\u63a7\u673a\u5236\uff0cLSTM\u80fd\u591f\u5728\u957f\u671f\u4f9d\u8d56\u95ee\u9898\u4e0a\u8868\u73b0\u5f97\u66f4\u597d\u3002<\/p>\n<p>\u6a21\u578b\u8bad\u7ec3\uff1a<\/p>\n<p>LSTM\u7684\u8bad\u7ec3\u901a\u5e38\u4f7f\u7528\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\u548c\u4f18\u5316\u7b97\u6cd5\uff08\u5982\u968f\u673a\u68af\u5ea6\u4e0b\u964d\uff09\u3002\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u901a\u8fc7\u8ba1\u7b97\u635f\u5931\u51fd\u6570\u5173\u4e8e\u6743\u91cd\u7684\u68af\u5ea6\uff0c\u5e76\u4f7f\u7528\u4f18\u5316\u7b97\u6cd5\u66f4\u65b0\u6743\u91cd\uff0c\u4ee5\u6700\u5c0f\u5316\u635f\u5931\u51fd\u6570\u3002\u6b64\u5916\uff0c\u4e3a\u4e86\u52a0\u901f\u8bad\u7ec3\u8fc7\u7a0b\u548c\u63d0\u9ad8\u6a21\u578b\u7684\u6cdb\u5316\u80fd\u529b\uff0c\u8fd8\u53ef\u4ee5\u91c7\u7528\u6b63\u5219\u5316\u6280\u672f\u3001\u96c6\u6210\u5b66\u4e60\u7b49\u65b9\u6cd5\u3002<\/p>\n<p>\u4f18\u70b9\uff1a<\/p>\n<ol class=\"list-paddingleft-1\" data-id=\"odd3d8fc-KdKi53aT\">\n<li data-id=\"ld70c578-QUOHbe20\">\u89e3\u51b3\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u95ee\u9898\uff1a\u901a\u8fc7\u5f15\u5165\u95e8\u63a7\u673a\u5236\uff0cLSTM\u80fd\u591f\u66f4\u597d\u5730\u5904\u7406\u957f\u671f\u4f9d\u8d56\u95ee\u9898\uff0c\u907f\u514d\u4e86\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u7684\u95ee\u9898\u3002<\/li>\n<li data-id=\"ld70c578-UmdZLAPD\">\u6784\u5efa\u975e\u5e38\u6df1\u7684\u7f51\u7edc\u7ed3\u6784\uff1a\u7531\u4e8e\u89e3\u51b3\u4e86\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u95ee\u9898\uff0cLSTM\u80fd\u591f\u6784\u5efa\u975e\u5e38\u6df1\u7684\u7f51\u7edc\u7ed3\u6784\uff0c\u4ece\u800c\u63d0\u9ad8\u4e86\u6a21\u578b\u7684\u6027\u80fd\u3002<\/li>\n<li data-id=\"ld70c578-8d5EA2cI\">\u5728\u591a\u4e2a\u4efb\u52a1\u4e0a\u53d6\u5f97\u4e86\u4f18\u5f02\u7684\u6027\u80fd\uff1a\u7531\u4e8e\u5176\u5f3a\u5927\u7684\u7279\u5f81\u5b66\u4e60\u548c\u8868\u793a\u80fd\u529b\uff0cLSTM\u5728\u591a\u4e2a\u4efb\u52a1\u4e0a\u53d6\u5f97\u4e86\u4f18\u5f02\u7684\u6027\u80fd\uff0c\u5982\u6587\u672c\u751f\u6210\u3001\u8bed\u97f3\u8bc6\u522b\u3001\u673a\u5668\u7ffb\u8bd1\u7b49\u3002<\/li>\n<\/ol>\n<p>\u7f3a\u70b9\uff1a<\/p>\n<ol class=\"list-paddingleft-1\" data-id=\"odd3d8fc-aN8ih3VO\">\n<li data-id=\"ld70c578-brFB27jT\">\u53c2\u6570\u8c03\u4f18\u96be\u5ea6\u5927\uff1aLSTM\u7684\u53c2\u6570\u6570\u91cf\u4f17\u591a\uff0c\u9700\u8981\u82b1\u8d39\u5927\u91cf\u65f6\u95f4\u548c\u7cbe\u529b\u8fdb\u884c\u8c03\u4f18\u548c\u8d85\u53c2\u6570\u9009\u62e9\u3002<\/li>\n<li data-id=\"ld70c578-1kGIjo0i\">\u5bf9\u521d\u59cb\u5316\u6743\u91cd\u654f\u611f\uff1aLSTM\u5bf9\u521d\u59cb\u5316\u6743\u91cd\u7684\u9009\u62e9\u654f\u611f\u5ea6\u9ad8\uff0c\u5982\u679c\u521d\u59cb\u5316\u6743\u91cd\u4e0d\u5408\u9002\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u8bad\u7ec3\u4e0d\u7a33\u5b9a\u6216\u8fc7\u62df\u5408\u95ee\u9898\u3002<\/li>\n<li data-id=\"ld70c578-ENbTkLff\">\u8ba1\u7b97\u91cf\u5927\uff1a\u7531\u4e8eLSTM\u901a\u5e38\u6784\u5efa\u975e\u5e38\u6df1\u7684\u7f51\u7edc\u7ed3\u6784\uff0c\u56e0\u6b64\u8ba1\u7b97\u91cf\u8f83\u5927\uff0c\u9700\u8981\u8f83\u9ad8\u7684\u8ba1\u7b97\u8d44\u6e90\u548c\u65f6\u95f4\u8fdb\u884c\u8bad\u7ec3\u3002<\/li>\n<\/ol>\n<p>\u4f7f\u7528\u573a\u666f\uff1a<\/p>\n<p>LSTM\u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\u9886\u57df\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u573a\u666f\uff0c\u5982\u6587\u672c\u751f\u6210\u3001\u673a\u5668\u7ffb\u8bd1\u3001\u8bed\u97f3\u8bc6\u522b\u7b49\u3002\u6b64\u5916\uff0cLSTM\u8fd8\u53ef\u4ee5\u7528\u4e8e\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u3001\u63a8\u8350\u7cfb\u7edf\u7b49\u9886\u57df\u3002<\/p>\n<p>Python\u793a\u4f8b\u4ee3\u7801\uff08\u7b80\u5316\u7248\uff09\uff1a<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\">\n<p><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_3\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">from keras.models import Sequential\r\nfrom keras.layers import LSTM, Dense\r\ndef lstm_model(input_shape, num_classes):\r\nmodel = Sequential()\r\nmodel.add(LSTM(units=128, input_shape=input_shape))  # \u6dfb\u52a0\u4e00\u4e2aLSTM\u5c42  \r\nmodel.add(Dense(units=num_classes, activatinotallow='softmax'))  # \u6dfb\u52a0\u4e00\u4e2a\u5168\u8fde\u63a5\u5c42  \r\nreturn model<\/code><\/pre>\n<ul id=\"code_id_3\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h4>5\u3001Word2Vec<\/h4>\n<p>Word2Vec\u6a21\u578b\u662f\u8868\u5f81\u5b66\u4e60\u7684\u5f00\u5c71\u4e4b\u4f5c\u3002\u7531Google\u7684\u79d1\u5b66\u5bb6\u4eec\u5f00\u53d1\u7684\u4e00\u79cd\u7528\u4e8e\u81ea\u7136\u8bed\u8a00\u5904\u7406\u7684(\u6d45\u5c42)\u795e\u7ecf\u7f51\u7edc\u6a21\u578b\u3002Word2Vec\u6a21\u578b\u7684\u76ee\u6807\u662f\u5c06\u6bcf\u4e2a\u8bcd\u5411\u91cf\u5316\u4e3a\u4e00\u4e2a\u56fa\u5b9a\u5927\u5c0f\u7684\u5411\u91cf\uff0c\u8fd9\u6837\u76f8\u4f3c\u7684\u8bcd\u5c31\u53ef\u4ee5\u88ab\u6620\u5c04\u5230\u76f8\u8fd1\u7684\u5411\u91cf\u7a7a\u95f4\u4e2d\u3002<\/p>\n<p><img data-dominant-color=\"010101\" data-has-transparency=\"true\" style=\"--dominant-color: #010101;\" loading=\"lazy\" decoding=\"async\" class=\"has-transparency alignnone size-full wp-image-19576\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/149f95c524217b70466116af42b078fc0beaa0-1.png\" width=\"1080\" height=\"675\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/149f95c524217b70466116af42b078fc0beaa0-1.png 1080w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/149f95c524217b70466116af42b078fc0beaa0-1-300x188.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/149f95c524217b70466116af42b078fc0beaa0-1-1024x640.png 1024w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/149f95c524217b70466116af42b078fc0beaa0-1-150x94.png 150w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/149f95c524217b70466116af42b078fc0beaa0-1-768x480.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<p>\u6a21\u578b\u539f\u7406<\/p>\n<p>Word2Vec\u6a21\u578b\u57fa\u4e8e\u795e\u7ecf\u7f51\u7edc\uff0c\u5229\u7528\u8f93\u5165\u7684\u8bcd\u9884\u6d4b\u5176\u4e0a\u4e0b\u6587\u8bcd\u3002\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u6a21\u578b\u5c1d\u8bd5\u5b66\u4e60\u5230\u6bcf\u4e2a\u8bcd\u7684\u5411\u91cf\u8868\u793a\uff0c\u4f7f\u5f97\u5728\u7ed9\u5b9a\u4e0a\u4e0b\u6587\u4e2d\u51fa\u73b0\u7684\u8bcd\u4e0e\u76ee\u6807\u8bcd\u7684\u5411\u91cf\u8868\u793a\u5c3d\u53ef\u80fd\u63a5\u8fd1\u3002\u8fd9\u79cd\u8bad\u7ec3\u65b9\u5f0f\u79f0\u4e3a\u201cSkip-gram\u201d\u6216\u201cContinuous Bag of Words\u201d\uff08CBOW\uff09\u3002<\/p>\n<p>\u6a21\u578b\u8bad\u7ec3<\/p>\n<p>\u8bad\u7ec3Word2Vec\u6a21\u578b\u9700\u8981\u5927\u91cf\u7684\u6587\u672c\u6570\u636e\u3002\u9996\u5148\uff0c\u5c06\u6587\u672c\u6570\u636e\u9884\u5904\u7406\u4e3a\u4e00\u7cfb\u5217\u7684\u8bcd\u6216n-gram\u3002\u7136\u540e\uff0c\u4f7f\u7528\u795e\u7ecf\u7f51\u7edc\u8bad\u7ec3\u8fd9\u4e9b\u8bcd\u6216n-gram\u7684\u4e0a\u4e0b\u6587\u3002\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u6a21\u578b\u4f1a\u4e0d\u65ad\u5730\u8c03\u6574\u8bcd\u7684\u5411\u91cf\u8868\u793a\uff0c\u4ee5\u6700\u5c0f\u5316\u9884\u6d4b\u8bef\u5dee\u3002<\/p>\n<p>\u4f18\u70b9<\/p>\n<ol class=\"list-paddingleft-1\" data-id=\"odd3d8fc-HE1f3qCl\">\n<li data-id=\"ld70c578-4bm6vx06\">\u8bed\u4e49\u76f8\u4f3c\u6027: Word2Vec\u80fd\u591f\u5b66\u4e60\u5230\u8bcd\u4e0e\u8bcd\u4e4b\u95f4\u7684\u8bed\u4e49\u5173\u7cfb\uff0c\u76f8\u4f3c\u7684\u8bcd\u5728\u5411\u91cf\u7a7a\u95f4\u4e2d\u8ddd\u79bb\u76f8\u8fd1\u3002<\/li>\n<li data-id=\"ld70c578-IjyRS6K0\">\u9ad8\u6548\u7684\u8bad\u7ec3: Word2Vec\u7684\u8bad\u7ec3\u8fc7\u7a0b\u76f8\u5bf9\u9ad8\u6548\uff0c\u53ef\u4ee5\u5728\u5927\u89c4\u6a21\u6587\u672c\u6570\u636e\u4e0a\u8bad\u7ec3\u3002<\/li>\n<li data-id=\"ld70c578-Ys1AXbv5\">\u53ef\u89e3\u91ca\u6027: Word2Vec\u7684\u8bcd\u5411\u91cf\u5177\u6709\u4e00\u5b9a\u7684\u53ef\u89e3\u91ca\u6027\uff0c\u53ef\u4ee5\u7528\u4e8e\u8bf8\u5982\u805a\u7c7b\u3001\u5206\u7c7b\u3001\u8bed\u4e49\u76f8\u4f3c\u6027\u8ba1\u7b97\u7b49\u4efb\u52a1\u3002<\/li>\n<\/ol>\n<p>\u7f3a\u70b9<\/p>\n<ol class=\"list-paddingleft-1\" start=\"4\" data-id=\"oaad4ec3-YVE3131L\">\n<li data-id=\"ld70c578-vVmb7wTm\">\u6570\u636e\u7a00\u758f\u6027: \u5bf9\u4e8e\u5927\u91cf\u672a\u5728\u8bad\u7ec3\u6570\u636e\u4e2d\u51fa\u73b0\u7684\u8bcd\uff0cWord2Vec\u53ef\u80fd\u65e0\u6cd5\u4e3a\u5176\u751f\u6210\u51c6\u786e\u7684\u5411\u91cf\u8868\u793a\u3002<\/li>\n<li data-id=\"ld70c578-j25JdRiI\">\u4e0a\u4e0b\u6587\u7a97\u53e3: Word2Vec\u53ea\u8003\u8651\u4e86\u56fa\u5b9a\u5927\u5c0f\u7684\u4e0a\u4e0b\u6587\uff0c\u53ef\u80fd\u4f1a\u5ffd\u7565\u66f4\u8fdc\u7684\u4f9d\u8d56\u5173\u7cfb\u3002<\/li>\n<li data-id=\"ld70c578-wZts4ENn\">\u8ba1\u7b97\u590d\u6742\u5ea6: Word2Vec\u7684\u8bad\u7ec3\u548c\u63a8\u7406\u8fc7\u7a0b\u9700\u8981\u5927\u91cf\u7684\u8ba1\u7b97\u8d44\u6e90\u3002<\/li>\n<li data-id=\"ld70c578-ZG0TSVYe\">\u53c2\u6570\u8c03\u6574: Word2Vec\u7684\u6027\u80fd\u9ad8\u5ea6\u4f9d\u8d56\u4e8e\u8d85\u53c2\u6570\uff08\u5982\u5411\u91cf\u7ef4\u5ea6\u3001\u7a97\u53e3\u5927\u5c0f\u3001\u5b66\u4e60\u7387\u7b49\uff09\u7684\u8bbe\u7f6e\u3002<\/li>\n<\/ol>\n<p>\u4f7f\u7528\u573a\u666f<\/p>\n<p>Word2Vec\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4efb\u52a1\uff0c\u5982\u6587\u672c\u5206\u7c7b\u3001\u60c5\u611f\u5206\u6790\u3001\u4fe1\u606f\u63d0\u53d6\u7b49\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528Word2Vec\u6765\u8bc6\u522b\u65b0\u95fb\u62a5\u9053\u7684\u60c5\u611f\u503e\u5411\uff08\u6b63\u9762\u6216\u8d1f\u9762\uff09\uff0c\u6216\u8005\u4ece\u5927\u91cf\u6587\u672c\u4e2d\u63d0\u53d6\u5173\u952e\u5b9e\u4f53\u6216\u6982\u5ff5\u3002<\/p>\n<p>Python\u793a\u4f8b\u4ee3\u7801<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\">\n<p><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_4\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">from gensim.models import Word2Vec  \r\nfrom nltk.tokenize import word_tokenize  \r\nfrom nltk.corpus import abc  \r\nimport nltk  \r\n  \r\n# \u4e0b\u8f7d\u548c\u52a0\u8f7dabc\u8bed\u6599\u5e93  \r\nnltk.download('abc')  \r\ncorpus = abc.sents()  \r\n  \r\n# \u5c06\u8bed\u6599\u5e93\u5206\u8bcd\u5e76\u8f6c\u6362\u4e3a\u5c0f\u5199  \r\nsentences = [[word.lower() for word in word_tokenize(text)] for text in corpus]  \r\n  \r\n# \u8bad\u7ec3Word2Vec\u6a21\u578b  \r\nmodel = Word2Vec(sentences, vector_size=100, window=5, min_count=5, workers=4)  \r\n  \r\n# \u67e5\u627e\u8bcd\"the\"\u7684\u5411\u91cf\u8868\u793a  \r\nvector = model.wv['the']  \r\n  \r\n# \u8ba1\u7b97\u4e0e\u5176\u4ed6\u8bcd\u7684\u76f8\u4f3c\u5ea6  \r\nsimilarity = model.wv.similarity('the', 'of')  \r\n  \r\n# \u6253\u5370\u76f8\u4f3c\u5ea6\u503c  \r\nprint(similarity)<\/code><\/pre>\n<ul id=\"code_id_4\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<li>20.<\/li>\n<li>21.<\/li>\n<li>22.<\/li>\n<li>23.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h4>6\u3001Transformer<\/h4>\n<p>\u80cc\u666f\uff1a<\/p>\n<p>\u5728\u6df1\u5ea6\u5b66\u4e60\u7684\u65e9\u671f\u9636\u6bb5\uff0c\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09\u5728\u56fe\u50cf\u8bc6\u522b\u548c\u81ea\u7136\u8bed\u8a00\u5904\u7406\u9886\u57df\u53d6\u5f97\u4e86\u663e\u8457\u7684\u6210\u529f\u3002\u7136\u800c\uff0c\u968f\u7740\u4efb\u52a1\u590d\u6742\u5ea6\u7684\u589e\u52a0\uff0c\u5e8f\u5217\u5230\u5e8f\u5217\uff08Seq2Seq\uff09\u6a21\u578b\u548c\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff08RNN\uff09\u6210\u4e3a\u5904\u7406\u5e8f\u5217\u6570\u636e\u7684\u5e38\u7528\u65b9\u6cd5\u3002\u5c3d\u7ba1RNN\u53ca\u5176\u53d8\u4f53\u5728\u67d0\u4e9b\u4efb\u52a1\u4e0a\u8868\u73b0\u826f\u597d\uff0c\u4f46\u5b83\u4eec\u5728\u5904\u7406\u957f\u5e8f\u5217\u65f6\u5bb9\u6613\u9047\u5230\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u95ee\u9898\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0cTransformer\u6a21\u578b\u88ab\u63d0\u51fa\u3002\u800c\u540e\u7684GPT\u3001Bert\u7b49\u5927\u6a21\u578b\u90fd\u662f\u57fa\u4e8eTransformer\u5b9e\u73b0\u4e86\u5353\u8d8a\u7684\u6027\u80fd\uff01<\/p>\n<p><img data-dominant-color=\"373632\" data-has-transparency=\"true\" style=\"--dominant-color: #373632;\" loading=\"lazy\" decoding=\"async\" class=\"has-transparency alignnone size-full wp-image-19577\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/d5ade8f05bb40ad648a8243750e510558705d8-1.png\" width=\"1080\" height=\"1014\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/d5ade8f05bb40ad648a8243750e510558705d8-1.png 1080w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/d5ade8f05bb40ad648a8243750e510558705d8-1-300x282.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/d5ade8f05bb40ad648a8243750e510558705d8-1-1024x961.png 1024w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/d5ade8f05bb40ad648a8243750e510558705d8-1-150x141.png 150w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/d5ade8f05bb40ad648a8243750e510558705d8-1-768x721.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<p>\u6a21\u578b\u539f\u7406\uff1a<\/p>\n<p>Transformer\u6a21\u578b\u4e3b\u8981\u7531\u4e24\u90e8\u5206\u7ec4\u6210\uff1a\u7f16\u7801\u5668\u548c\u89e3\u7801\u5668\u3002\u6bcf\u4e2a\u90e8\u5206\u90fd\u7531\u591a\u4e2a\u76f8\u540c\u7684\u201c\u5c42\u201d\u7ec4\u6210\u3002\u6bcf\u4e00\u5c42\u5305\u542b\u4e24\u4e2a\u5b50\u5c42\uff1a\u81ea\u6ce8\u610f\u529b\u5b50\u5c42\u548c\u7ebf\u6027\u524d\u9988\u795e\u7ecf\u7f51\u7edc\u5b50\u5c42\u3002\u81ea\u6ce8\u610f\u529b\u5b50\u5c42\u5229\u7528\u70b9\u79ef\u6ce8\u610f\u529b\u673a\u5236\u8ba1\u7b97\u8f93\u5165\u5e8f\u5217\u4e2d\u6bcf\u4e2a\u4f4d\u7f6e\u7684\u8868\u793a\uff0c\u800c\u7ebf\u6027\u524d\u9988\u795e\u7ecf\u7f51\u7edc\u5b50\u5c42\u5219\u5c06\u81ea\u6ce8\u610f\u529b\u5c42\u7684\u8f93\u51fa\u4f5c\u4e3a\u8f93\u5165\uff0c\u5e76\u4ea7\u751f\u4e00\u4e2a\u8f93\u51fa\u8868\u793a\u3002\u6b64\u5916\uff0c\u7f16\u7801\u5668\u548c\u89e3\u7801\u5668\u90fd\u5305\u542b\u4e00\u4e2a\u4f4d\u7f6e\u7f16\u7801\u5c42\uff0c\u7528\u4e8e\u6355\u83b7\u8f93\u5165\u5e8f\u5217\u4e2d\u7684\u4f4d\u7f6e\u4fe1\u606f\u3002<\/p>\n<p>\u6a21\u578b\u8bad\u7ec3\uff1a<\/p>\n<p>Transformer\u6a21\u578b\u7684\u8bad\u7ec3\u901a\u5e38\u4f7f\u7528\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\u548c\u4f18\u5316\u7b97\u6cd5\uff08\u5982\u968f\u673a\u68af\u5ea6\u4e0b\u964d\uff09\u3002\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u901a\u8fc7\u8ba1\u7b97\u635f\u5931\u51fd\u6570\u5173\u4e8e\u6743\u91cd\u7684\u68af\u5ea6\uff0c\u5e76\u4f7f\u7528\u4f18\u5316\u7b97\u6cd5\u66f4\u65b0\u6743\u91cd\uff0c\u4ee5\u6700\u5c0f\u5316\u635f\u5931\u51fd\u6570\u3002\u6b64\u5916\uff0c\u4e3a\u4e86\u52a0\u901f\u8bad\u7ec3\u8fc7\u7a0b\u548c\u63d0\u9ad8\u6a21\u578b\u7684\u6cdb\u5316\u80fd\u529b\uff0c\u8fd8\u53ef\u4ee5\u91c7\u7528\u6b63\u5219\u5316\u6280\u672f\u3001\u96c6\u6210\u5b66\u4e60\u7b49\u65b9\u6cd5\u3002<\/p>\n<p>\u4f18\u70b9\uff1a<\/p>\n<ol class=\"list-paddingleft-1\" data-id=\"odd3d8fc-rPN3k5X1\">\n<li data-id=\"ld70c578-CiCIkR6C\">\u89e3\u51b3\u4e86\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u95ee\u9898\uff1a\u7531\u4e8eTransformer\u6a21\u578b\u91c7\u7528\u81ea\u6ce8\u610f\u529b\u673a\u5236\uff0c\u5b83\u80fd\u591f\u66f4\u597d\u5730\u6355\u6349\u5e8f\u5217\u4e2d\u7684\u957f\u671f\u4f9d\u8d56\u5173\u7cfb\uff0c\u4ece\u800c\u907f\u514d\u4e86\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u7684\u95ee\u9898\u3002<\/li>\n<li data-id=\"ld70c578-NHBG8GxP\">\u9ad8\u6548\u7684\u5e76\u884c\u8ba1\u7b97\u80fd\u529b\uff1a\u7531\u4e8eTransformer\u6a21\u578b\u7684\u8ba1\u7b97\u662f\u53ef\u5e76\u884c\u7684\uff0c\u56e0\u6b64\u5728GPU\u4e0a\u53ef\u4ee5\u5feb\u901f\u5730\u8fdb\u884c\u8bad\u7ec3\u548c\u63a8\u65ad\u3002<\/li>\n<li data-id=\"ld70c578-WsqrAxuX\">\u5728\u591a\u4e2a\u4efb\u52a1\u4e0a\u53d6\u5f97\u4e86\u4f18\u5f02\u7684\u6027\u80fd\uff1a\u7531\u4e8e\u5176\u5f3a\u5927\u7684\u7279\u5f81\u5b66\u4e60\u548c\u8868\u793a\u80fd\u529b\uff0cTransformer\u6a21\u578b\u5728\u591a\u4e2a\u4efb\u52a1\u4e0a\u53d6\u5f97\u4e86\u4f18\u5f02\u7684\u6027\u80fd\uff0c\u5982\u673a\u5668\u7ffb\u8bd1\u3001\u6587\u672c\u5206\u7c7b\u3001\u8bed\u97f3\u8bc6\u522b\u7b49\u3002<\/li>\n<\/ol>\n<p>\u7f3a\u70b9\uff1a<\/p>\n<ol class=\"list-paddingleft-1\" data-id=\"odd3d8fc-dJsF9OKl\">\n<li data-id=\"ld70c578-Z3V0xMpr\">\u8ba1\u7b97\u91cf\u5927\uff1a\u7531\u4e8eTransformer\u6a21\u578b\u7684\u8ba1\u7b97\u662f\u53ef\u5e76\u884c\u7684\uff0c\u56e0\u6b64\u9700\u8981\u5927\u91cf\u7684\u8ba1\u7b97\u8d44\u6e90\u8fdb\u884c\u8bad\u7ec3\u548c\u63a8\u65ad\u3002<\/li>\n<li data-id=\"ld70c578-SM4NBrSF\">\u5bf9\u521d\u59cb\u5316\u6743\u91cd\u654f\u611f\uff1aTransformer\u6a21\u578b\u5bf9\u521d\u59cb\u5316\u6743\u91cd\u7684\u9009\u62e9\u654f\u611f\u5ea6\u9ad8\uff0c\u5982\u679c\u521d\u59cb\u5316\u6743\u91cd\u4e0d\u5408\u9002\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u8bad\u7ec3\u4e0d\u7a33\u5b9a\u6216\u8fc7\u62df\u5408\u95ee\u9898\u3002<\/li>\n<li data-id=\"ld70c578-WjzGRczp\">\u65e0\u6cd5\u5b66\u4e60\u957f\u671f\u4f9d\u8d56\u5173\u7cfb\uff1a\u5c3d\u7ba1Transformer\u6a21\u578b\u89e3\u51b3\u4e86\u68af\u5ea6\u6d88\u5931\u548c\u6a21\u578b\u9000\u5316\u95ee\u9898\uff0c\u4f46\u5728\u5904\u7406\u975e\u5e38\u957f\u7684\u5e8f\u5217\u65f6\u4ecd\u7136\u5b58\u5728\u6311\u6218\u3002<\/li>\n<\/ol>\n<p>\u4f7f\u7528\u573a\u666f\uff1a<\/p>\n<p>Transformer\u6a21\u578b\u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\u9886\u57df\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u573a\u666f\uff0c\u5982\u673a\u5668\u7ffb\u8bd1\u3001\u6587\u672c\u5206\u7c7b\u3001\u6587\u672c\u751f\u6210\u7b49\u3002\u6b64\u5916\uff0cTransformer\u6a21\u578b\u8fd8\u53ef\u4ee5\u7528\u4e8e\u56fe\u50cf\u8bc6\u522b\u3001\u8bed\u97f3\u8bc6\u522b\u7b49\u9886\u57df\u3002<\/p>\n<p>Python\u793a\u4f8b\u4ee3\u7801\uff08\u7b80\u5316\u7248\uff09\uff1a<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\">\n<p><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_5\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">import torch  \r\nimport torch.nn as nn  \r\nimport torch.nn.functional as F  \r\n  \r\nclass TransformerModel(nn.Module):  \r\n    def __init__(self, vocab_size, embedding_dim, num_heads, num_layers, dropout_rate=0.5):  \r\n        super(TransformerModel, self).__init__()  \r\n        self.embedding = nn.Embedding(vocab_size, embedding_dim)  \r\n        self.transformer = nn.Transformer(d_model=embedding_dim, nhead=num_heads, num_encoder_layers=num_layers, num_decoder_layers=num_layers, dropout=dropout_rate)  \r\n        self.fc = nn.Linear(embedding_dim, vocab_size)  \r\n      \r\n    def forward(self, src, tgt):  \r\n        embedded = self.embedding(src)  \r\n        output = self.transformer(embedded)  \r\n        output = self.fc(output)  \r\n        return output\r\n\r\n pip install transformers<\/code><\/pre>\n<ul id=\"code_id_5\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h4>7\u3001\u751f\u6210\u5bf9\u6297\u7f51\u7edc\uff08GAN\uff09<\/h4>\n<p>GAN\u7684\u601d\u60f3\u6e90\u4e8e\u535a\u5f08\u8bba\u4e2d\u7684\u96f6\u548c\u6e38\u620f\uff0c\u5176\u4e2d\u4e00\u4e2a\u73a9\u5bb6\u8bd5\u56fe\u751f\u6210\u6700\u903c\u771f\u7684\u5047\u6570\u636e\uff0c\u800c\u53e6\u4e00\u4e2a\u73a9\u5bb6\u5219\u5c1d\u8bd5\u533a\u5206\u771f\u5b9e\u6570\u636e\u4e0e\u5047\u6570\u636e\u3002GAN\u7531\u8499\u63d0\u970d\u5c14\u95ee\u9898\uff08\u4e00\u79cd\u751f\u6210\u6a21\u578b\u4e0e\u5224\u522b\u6a21\u578b\u7ec4\u5408\u7684\u95ee\u9898\uff09\u6f14\u53d8\u800c\u6765\uff0c\u4f46\u4e0e\u8499\u63d0\u970d\u5c14\u95ee\u9898\u4e0d\u540c\uff0cGAN\u4e0d\u5f3a\u8c03\u903c\u8fd1\u67d0\u4e9b\u6982\u7387\u5206\u5e03\u6216\u751f\u6210\u67d0\u79cd\u6837\u672c\uff0c\u800c\u662f\u76f4\u63a5\u4f7f\u7528\u751f\u6210\u6a21\u578b\u4e0e\u5224\u522b\u6a21\u578b\u8fdb\u884c\u5bf9\u6297\u3002<\/p>\n<p><img data-dominant-color=\"eceae8\" data-has-transparency=\"false\" style=\"--dominant-color: #eceae8;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent alignnone size-full wp-image-19578\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/491685f772ed76c6a7f09227db4d2055f39ca8-1.png\" width=\"1080\" height=\"531\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/491685f772ed76c6a7f09227db4d2055f39ca8-1.png 1080w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/491685f772ed76c6a7f09227db4d2055f39ca8-1-300x148.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/491685f772ed76c6a7f09227db4d2055f39ca8-1-1024x503.png 1024w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/491685f772ed76c6a7f09227db4d2055f39ca8-1-150x74.png 150w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/491685f772ed76c6a7f09227db4d2055f39ca8-1-768x378.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<p>\u6a21\u578b\u539f\u7406\uff1a<\/p>\n<p>GAN\u7531\u4e24\u90e8\u5206\u7ec4\u6210\uff1a\u751f\u6210\u5668\uff08Generator\uff09\u548c\u5224\u522b\u5668\uff08Discriminator\uff09\u3002\u751f\u6210\u5668\u7684\u4efb\u52a1\u662f\u751f\u6210\u5047\u6570\u636e\uff0c\u800c\u5224\u522b\u5668\u7684\u4efb\u52a1\u662f\u5224\u65ad\u8f93\u5165\u7684\u6570\u636e\u662f\u6765\u81ea\u771f\u5b9e\u6570\u636e\u96c6\u8fd8\u662f\u751f\u6210\u5668\u751f\u6210\u7684\u5047\u6570\u636e\u3002\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u751f\u6210\u5668\u548c\u5224\u522b\u5668\u8fdb\u884c\u5bf9\u6297\uff0c\u4e0d\u65ad\u8c03\u6574\u53c2\u6570\uff0c\u76f4\u5230\u8fbe\u5230\u4e00\u4e2a\u5e73\u8861\u72b6\u6001\u3002\u6b64\u65f6\uff0c\u751f\u6210\u5668\u751f\u6210\u7684\u5047\u6570\u636e\u8db3\u591f\u903c\u771f\uff0c\u4f7f\u5f97\u5224\u522b\u5668\u65e0\u6cd5\u533a\u5206\u771f\u5b9e\u6570\u636e\u4e0e\u5047\u6570\u636e\u3002<\/p>\n<p>\u6a21\u578b\u8bad\u7ec3\uff1a<\/p>\n<p>GAN\u7684\u8bad\u7ec3\u8fc7\u7a0b\u662f\u4e00\u4e2a\u4f18\u5316\u95ee\u9898\u3002\u5728\u6bcf\u4e2a\u8bad\u7ec3\u6b65\u9aa4\u4e2d\uff0c\u9996\u5148\u4f7f\u7528\u5f53\u524d\u53c2\u6570\u4e0b\u7684\u751f\u6210\u5668\u751f\u6210\u5047\u6570\u636e\uff0c\u7136\u540e\u4f7f\u7528\u5224\u522b\u5668\u5224\u65ad\u8fd9\u4e9b\u6570\u636e\u662f\u771f\u5b9e\u7684\u8fd8\u662f\u751f\u6210\u7684\u3002\u63a5\u7740\uff0c\u6839\u636e\u8fd9\u4e2a\u5224\u65ad\u7ed3\u679c\u66f4\u65b0\u5224\u522b\u5668\u7684\u53c2\u6570\u3002\u540c\u65f6\uff0c\u4e3a\u4e86\u9632\u6b62\u5224\u522b\u5668\u8fc7\u62df\u5408\uff0c\u8fd8\u9700\u8981\u5bf9\u751f\u6210\u5668\u8fdb\u884c\u8bad\u7ec3\uff0c\u4f7f\u5f97\u751f\u6210\u7684\u5047\u6570\u636e\u80fd\u591f\u6b3a\u9a97\u5224\u522b\u5668\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u53cd\u590d\u8fdb\u884c\uff0c\u76f4\u5230\u8fbe\u5230\u5e73\u8861\u72b6\u6001\u3002<\/p>\n<p>\u4f18\u70b9\uff1a<\/p>\n<ol class=\"list-paddingleft-1\" data-id=\"odd3d8fc-lUetQs8M\">\n<li data-id=\"ld70c578-j1q3U73Q\">\u5f3a\u5927\u7684\u751f\u6210\u80fd\u529b\uff1aGAN\u80fd\u591f\u5b66\u4e60\u5230\u6570\u636e\u7684\u5185\u5728\u7ed3\u6784\u548c\u5206\u5e03\uff0c\u4ece\u800c\u751f\u6210\u975e\u5e38\u903c\u771f\u7684\u5047\u6570\u636e\u3002<\/li>\n<li data-id=\"ld70c578-Tr8o29Oo\">\u65e0\u9700\u663e\u5f0f\u76d1\u7763\uff1aGAN\u7684\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u4e0d\u9700\u8981\u663e\u5f0f\u7684\u6807\u7b7e\u4fe1\u606f\uff0c\u53ea\u9700\u8981\u771f\u5b9e\u6570\u636e\u5373\u53ef\u3002<\/li>\n<li data-id=\"ld70c578-SWyQcn7X\">\u7075\u6d3b\u6027\u9ad8\uff1aGAN\u53ef\u4ee5\u4e0e\u5176\u4ed6\u6a21\u578b\u7ed3\u5408\u4f7f\u7528\uff0c\u4f8b\u5982\u4e0e\u81ea\u7f16\u7801\u5668\u7ed3\u5408\u5f62\u6210AutoGAN\uff0c\u6216\u8005\u4e0e\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7ed3\u5408\u5f62\u6210DCGAN\u7b49\u3002<\/li>\n<\/ol>\n<p>\u7f3a\u70b9\uff1a<\/p>\n<ol class=\"list-paddingleft-1\" data-id=\"odd3d8fc-l5IWOpEB\">\n<li data-id=\"ld70c578-OTKOwmvO\">\u8bad\u7ec3\u4e0d\u7a33\u5b9a\uff1aGAN\u7684\u8bad\u7ec3\u8fc7\u7a0b\u4e0d\u7a33\u5b9a\uff0c\u5bb9\u6613\u9677\u5165\u6a21\u5f0f\u5d29\u6e83\uff08mode collapse\uff09\u7684\u95ee\u9898\uff0c\u5373\u751f\u6210\u5668\u53ea\u751f\u6210\u67d0\u4e00\u79cd\u6837\u672c\uff0c\u5bfc\u81f4\u5224\u522b\u5668\u65e0\u6cd5\u6b63\u786e\u5224\u65ad\u3002<\/li>\n<li data-id=\"ld70c578-zpGvi2lQ\">\u96be\u4ee5\u8c03\u8bd5\uff1aGAN\u7684\u8c03\u8bd5\u6bd4\u8f83\u56f0\u96be\uff0c\u56e0\u4e3a\u751f\u6210\u5668\u548c\u5224\u522b\u5668\u4e4b\u95f4\u5b58\u5728\u590d\u6742\u7684\u76f8\u4e92\u4f5c\u7528\u3002<\/li>\n<li data-id=\"ld70c578-5QSdrPNF\">\u96be\u4ee5\u8bc4\u4f30\uff1a\u7531\u4e8eGAN\u7684\u751f\u6210\u80fd\u529b\u5f88\u5f3a\uff0c\u5f88\u96be\u8bc4\u4f30\u5176\u751f\u6210\u7684\u5047\u6570\u636e\u7684\u771f\u5b9e\u6027\u548c\u591a\u6837\u6027\u3002<\/li>\n<\/ol>\n<p>\u4f7f\u7528\u573a\u666f\uff1a<\/p>\n<ol class=\"list-paddingleft-1\" data-id=\"odd3d8fc-MpN5PqCI\">\n<li data-id=\"ld70c578-fNt1Z75P\">\u56fe\u50cf\u751f\u6210\uff1aGAN\u6700\u5e38\u7528\u4e8e\u56fe\u50cf\u751f\u6210\u4efb\u52a1\uff0c\u53ef\u4ee5\u751f\u6210\u5404\u79cd\u98ce\u683c\u7684\u56fe\u50cf\uff0c\u4f8b\u5982\u6839\u636e\u6587\u5b57\u63cf\u8ff0\u751f\u6210\u56fe\u50cf\u3001\u5c06\u4e00\u5e45\u56fe\u50cf\u8f6c\u6362\u4e3a\u53e6\u4e00\u98ce\u683c\u7b49\u3002<\/li>\n<li data-id=\"ld70c578-ChSA1Z7Z\">\u6570\u636e\u589e\u5f3a\uff1aGAN\u53ef\u4ee5\u7528\u4e8e\u751f\u6210\u7c7b\u4f3c\u771f\u5b9e\u6570\u636e\u7684\u5047\u6570\u636e\uff0c\u7528\u4e8e\u6269\u5145\u6570\u636e\u96c6\u6216\u6539\u8fdb\u6a21\u578b\u7684\u6cdb\u5316\u80fd\u529b\u3002<\/li>\n<li data-id=\"ld70c578-ZAYNZqlF\">\u56fe\u50cf\u4fee\u590d\uff1aGAN\u53ef\u4ee5\u7528\u4e8e\u4fee\u590d\u56fe\u50cf\u4e2d\u7684\u7f3a\u9677\u6216\u53bb\u9664\u56fe\u50cf\u4e2d\u7684\u566a\u58f0\u3002<\/li>\n<li data-id=\"ld70c578-vl1Q8igR\">\u89c6\u9891\u751f\u6210\uff1a\u57fa\u4e8eGAN\u7684\u89c6\u9891\u751f\u6210\u662f\u5f53\u524d\u7814\u7a76\u7684\u70ed\u70b9\u4e4b\u4e00\uff0c\u53ef\u4ee5\u751f\u6210\u5404\u79cd\u98ce\u683c\u7684\u89c6\u9891\u3002<\/li>\n<\/ol>\n<p>\u7b80\u5355\u7684Python\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684GAN\u793a\u4f8b\u4ee3\u7801\uff0c\u4f7f\u7528PyTorch\u5b9e\u73b0\uff1a<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\">\n<p><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_6\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">import torch\r\nimport torch.nn as nn\r\nimport torch.optim as optim\r\nimport torch.nn.functional as F\r\n# \u5b9a\u4e49\u751f\u6210\u5668\u548c\u5224\u522b\u5668\u7f51\u7edc\u7ed3\u6784  \r\nclass Generator(nn.Module):\r\ndef __init__(self, input_dim, output_dim):\r\nsuper(Generator, self).__init__()\r\nself.model = nn.Sequential(\r\nnn.Linear(input_dim, 128),\r\nnn.ReLU(),\r\nnn.Linear(128, output_dim),\r\nnn.Sigmoid()\r\n)\r\ndef forward(self, x):\r\nreturn self.model(x)\r\nclass Discriminator(nn.Module):\r\ndef __init__(self, input_dim):\r\nsuper(Discriminator, self).__init__()\r\nself.model = nn.Sequential(\r\nnn.Linear(input_dim, 128),\r\nnn.ReLU(),\r\nnn.Linear(128, 1),\r\nnn.Sigmoid()\r\n)\r\ndef forward(self, x):\r\nreturn self.model(x)\r\n# \u5b9e\u4f8b\u5316\u751f\u6210\u5668\u548c\u5224\u522b\u5668\u5bf9\u8c61  \r\ninput_dim = 100  # \u8f93\u5165\u7ef4\u5ea6\u53ef\u6839\u636e\u5b9e\u9645\u9700\u6c42\u8c03\u6574  \r\noutput_dim = 784  # \u5bf9\u4e8eMNIST\u6570\u636e\u96c6\uff0c\u8f93\u51fa\u7ef4\u5ea6\u4e3a28*28=784  \r\ngen = Generator(input_dim, output_dim)\r\ndisc = Discriminator(output_dim)\r\n# \u5b9a\u4e49\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u5668  \r\ncriterion = nn.BCELoss()  # \u4e8c\u5206\u7c7b\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570\u9002\u7528\u4e8eGAN\u7684\u5224\u522b\u5668\u90e8\u5206\u548c\u751f\u6210\u5668\u7684logistic\u635f\u5931\u90e8\u5206\u3002\u4f46\u662f\uff0c\u901a\u5e38\u66f4\u5e38\u89c1\u7684\u9009\u62e9\u662f\u91c7\u7528\u4e8c\u5143\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570\uff08binary cross<\/code><\/pre>\n<ul id=\"code_id_6\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<li>20.<\/li>\n<li>21.<\/li>\n<li>22.<\/li>\n<li>23.<\/li>\n<li>24.<\/li>\n<li>25.<\/li>\n<li>26.<\/li>\n<li>27.<\/li>\n<li>28.<\/li>\n<li>29.<\/li>\n<li>30.<\/li>\n<li>31.<\/li>\n<li>32.<\/li>\n<li>33.<\/li>\n<li>34.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h4>8\u3001Diffusion\u6269\u6563\u6a21\u578b<\/h4>\n<p>Diffusion\u6a21\u578b\u662f\u4e00\u79cd\u57fa\u4e8e\u6df1\u5ea6\u5b66\u4e60\u7684\u751f\u6210\u6a21\u578b\uff0c\u5b83\u4e3b\u8981\u7528\u4e8e\u751f\u6210\u8fde\u7eed\u6570\u636e\uff0c\u5982\u56fe\u50cf\u3001\u97f3\u9891\u7b49\u3002Diffusion\u6a21\u578b\u7684\u6838\u5fc3\u601d\u60f3\u662f\u901a\u8fc7\u9010\u6b65\u6dfb\u52a0\u566a\u58f0\u6765\u5c06\u590d\u6742\u6570\u636e\u5206\u5e03\u8f6c\u5316\u4e3a\u7b80\u5355\u7684\u9ad8\u65af\u5206\u5e03\uff0c\u7136\u540e\u518d\u901a\u8fc7\u9010\u6b65\u53bb\u9664\u566a\u58f0\u6765\u4ece\u7b80\u5355\u5206\u5e03\u4e2d\u751f\u6210\u6570\u636e\u3002<\/p>\n<p><img data-dominant-color=\"dbdadb\" data-has-transparency=\"false\" style=\"--dominant-color: #dbdadb;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent alignnone size-full wp-image-19579\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/d1630847433aada6e996698449ced21f9c29b0-1.png\" width=\"1080\" height=\"482\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/d1630847433aada6e996698449ced21f9c29b0-1.png 1080w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/d1630847433aada6e996698449ced21f9c29b0-1-300x134.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/d1630847433aada6e996698449ced21f9c29b0-1-1024x457.png 1024w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/d1630847433aada6e996698449ced21f9c29b0-1-150x67.png 150w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/d1630847433aada6e996698449ced21f9c29b0-1-768x343.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<p>\u6a21\u578b\u539f\u7406<\/p>\n<p>Diffusion\u6a21\u578b\u5305\u542b\u4e24\u4e2a\u4e3b\u8981\u8fc7\u7a0b\uff1a\u524d\u5411\u6269\u6563\u8fc7\u7a0b\u548c\u53cd\u5411\u6269\u6563\u8fc7\u7a0b\u3002<\/p>\n<p>\u524d\u5411\u6269\u6563\u8fc7\u7a0b\uff1a<\/p>\n<ul data-id=\"u738a58b-9d81g8dG\">\n<li data-id=\"ld70c578-AOVxT89A\">\u4ece\u771f\u5b9e\u6570\u636e\u5206\u5e03\u4e2d\u91c7\u6837\u4e00\u4e2a\u6570\u636e\u70b9(x_0)\u3002<\/li>\n<li data-id=\"ld70c578-A48zhF9t\">\u5728(T)\u4e2a\u65f6\u95f4\u6b65\u5185\uff0c\u9010\u6b65\u5411(x_0)\u4e2d\u6dfb\u52a0\u566a\u58f0\uff0c\u751f\u6210\u4e00\u7cfb\u5217\u9010\u6e10\u8fdc\u79bb\u771f\u5b9e\u6570\u636e\u5206\u5e03\u7684\u566a\u58f0\u6570\u636e\u70b9(x_1, x_2, &#8230;, x_T)\u3002<\/li>\n<li data-id=\"ld70c578-PGcxKrOG\">\u8fd9\u4e2a\u8fc7\u7a0b\u53ef\u4ee5\u770b\u4f5c\u662f\u5c06\u6570\u636e\u5206\u5e03\u9010\u6e10\u8f6c\u5316\u4e3a\u9ad8\u65af\u5206\u5e03\u3002<\/li>\n<\/ul>\n<p>\u53cd\u5411\u6269\u6563\u8fc7\u7a0b(\u4e5f\u79f0\u4e3a\u53bb\u566a\u8fc7\u7a0b)\uff1a<\/p>\n<ul data-id=\"u738a58b-b3FIbanC\">\n<li data-id=\"ld70c578-auRuwoTm\">\u4ece\u566a\u58f0\u6570\u636e\u5206\u5e03(x_T)\u5f00\u59cb\uff0c\u9010\u6b65\u53bb\u9664\u566a\u58f0\uff0c\u751f\u6210\u4e00\u7cfb\u5217\u9010\u6e10\u63a5\u8fd1\u771f\u5b9e\u6570\u636e\u5206\u5e03\u7684\u6570\u636e\u70b9(x_{T-1}, x_{T-2}, &#8230;, x_0)\u3002<\/li>\n<li data-id=\"ld70c578-Upwnf0Wf\">\u8fd9\u4e2a\u8fc7\u7a0b\u662f\u901a\u8fc7\u5b66\u4e60\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u6765\u9884\u6d4b\u6bcf\u4e00\u6b65\u7684\u566a\u58f0\uff0c\u5e76\u7528\u8fd9\u4e2a\u9884\u6d4b\u6765\u9010\u6b65\u53bb\u566a\u3002<\/li>\n<\/ul>\n<p class=\"mask_ellipsis_extra\">\u6a21\u578b\u8bad\u7ec3<\/p>\n<p class=\"mask_ellipsis_extra\">\u8bad\u7ec3Diffusion\u6a21\u578b\u901a\u5e38\u6d89\u53ca\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ol start=\"1\" data-id=\"ob7246f7-VCfEmWbH\">\n<li data-id=\"ld70c578-kxKT8wFf\">\u524d\u5411\u6269\u6563\uff1a\u5bf9\u8bad\u7ec3\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e2a\u6837\u672c(x_0)\uff0c\u6309\u7167\u9884\u5b9a\u7684\u566a\u58f0\u8c03\u5ea6\u65b9\u6848\uff0c\u751f\u6210\u5bf9\u5e94\u7684\u566a\u58f0\u5e8f\u5217(x_1, x_2, &#8230;, x_T)\u3002<\/li>\n<li data-id=\"ld70c578-g31cZmJq\">\u566a\u58f0\u9884\u6d4b\uff1a\u5bf9\u4e8e\u6bcf\u4e2a\u65f6\u95f4\u6b65(t)\uff0c\u8bad\u7ec3\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u6765\u9884\u6d4b(x_t)\u4e2d\u7684\u566a\u58f0\u3002\u8fd9\u4e2a\u795e\u7ecf\u7f51\u7edc\u901a\u5e38\u662f\u4e00\u4e2a\u6761\u4ef6\u53d8\u5206\u81ea\u7f16\u7801\u5668(Conditional Variational Autoencoder, CVAE)\uff0c\u5b83\u63a5\u6536(x_t)\u548c\u65f6\u95f4\u6b65(t)\u4f5c\u4e3a\u8f93\u5165\uff0c\u5e76\u8f93\u51fa\u9884\u6d4b\u7684\u566a\u58f0\u3002<\/li>\n<li data-id=\"ld70c578-pg762ojN\">\u4f18\u5316\uff1a\u901a\u8fc7\u6700\u5c0f\u5316\u771f\u5b9e\u566a\u58f0\u548c\u9884\u6d4b\u566a\u58f0\u4e4b\u95f4\u7684\u5dee\u5f02\u6765\u4f18\u5316\u795e\u7ecf\u7f51\u7edc\u53c2\u6570\u3002\u5e38\u7528\u7684\u635f\u5931\u51fd\u6570\u662f\u5747\u65b9\u8bef\u5dee(Mean Squared Error, MSE)\u3002<\/li>\n<\/ol>\n<p>\u4f18\u70b9<\/p>\n<ul data-id=\"u738a58b-JXIeTYXS\">\n<li data-id=\"ld70c578-3eslRFkz\">\u5f3a\u5927\u7684\u751f\u6210\u80fd\u529b\uff1aDiffusion\u6a21\u578b\u80fd\u591f\u751f\u6210\u9ad8\u8d28\u91cf\u3001\u591a\u6837\u5316\u7684\u6570\u636e\u6837\u672c\u3002<\/li>\n<li data-id=\"ld70c578-T91Szrtb\">\u6e10\u8fdb\u5f0f\u751f\u6210\uff1a\u6a21\u578b\u53ef\u4ee5\u5728\u751f\u6210\u8fc7\u7a0b\u4e2d\u63d0\u4f9b\u4e2d\u95f4\u7ed3\u679c\uff0c\u8fd9\u6709\u52a9\u4e8e\u7406\u89e3\u6a21\u578b\u7684\u751f\u6210\u8fc7\u7a0b\u3002<\/li>\n<li data-id=\"ld70c578-qiVJRXEz\">\u7a33\u5b9a\u8bad\u7ec3\uff1a\u76f8\u8f83\u4e8e\u5176\u4ed6\u4e00\u4e9b\u751f\u6210\u6a21\u578b(\u5982GANs)\uff0cDiffusion\u6a21\u578b\u901a\u5e38\u66f4\u5bb9\u6613\u8bad\u7ec3\uff0c\u5e76\u4e14\u4e0d\u592a\u5bb9\u6613\u51fa\u73b0\u6a21\u5f0f\u5d29\u6e83(mode collapse)\u95ee\u9898\u3002<\/li>\n<\/ul>\n<p>\u7f3a\u70b9<\/p>\n<ul data-id=\"u738a58b-ii45BgF8\">\n<li data-id=\"ld70c578-SfulHiKy\">\u8ba1\u7b97\u91cf\u5927\uff1a\u7531\u4e8e\u9700\u8981\u5728\u591a\u4e2a\u65f6\u95f4\u6b65\u4e0a\u8fdb\u884c\u524d\u5411\u548c\u53cd\u5411\u6269\u6563\uff0cDiffusion\u6a21\u578b\u7684\u8bad\u7ec3\u548c\u751f\u6210\u8fc7\u7a0b\u901a\u5e38\u6bd4\u8f83\u8017\u65f6\u3002<\/li>\n<li data-id=\"ld70c578-K7WD4JrH\">\u53c2\u6570\u6570\u91cf\u591a\uff1a\u5bf9\u4e8e\u6bcf\u4e2a\u65f6\u95f4\u6b65\uff0c\u90fd\u9700\u8981\u4e00\u4e2a\u5355\u72ec\u7684\u795e\u7ecf\u7f51\u7edc\u8fdb\u884c\u566a\u58f0\u9884\u6d4b\uff0c\u8fd9\u5bfc\u81f4\u6a21\u578b\u53c2\u6570\u6570\u91cf\u8f83\u591a\u3002<\/li>\n<\/ul>\n<p>\u4f7f\u7528\u573a\u666f<\/p>\n<p>Diffusion\u6a21\u578b\u9002\u7528\u4e8e\u9700\u8981\u751f\u6210\u8fde\u7eed\u6570\u636e\u7684\u573a\u666f\uff0c\u5982\u56fe\u50cf\u751f\u6210\u3001\u97f3\u9891\u751f\u6210\u3001\u89c6\u9891\u751f\u6210\u7b49\u3002\u6b64\u5916\uff0c\u7531\u4e8e\u6a21\u578b\u5177\u6709\u6e10\u8fdb\u5f0f\u751f\u6210\u7684\u7279\u70b9\uff0c\u5b83\u8fd8\u53ef\u4ee5\u7528\u4e8e\u6570\u636e\u63d2\u503c\u3001\u98ce\u683c\u8fc1\u79fb\u7b49\u4efb\u52a1\u3002<\/p>\n<p>Python\u793a\u4f8b\u4ee3\u7801<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5316\u7684Diffusion\u6a21\u578b\u8bad\u7ec3\u7684\u793a\u4f8b\u4ee3\u7801\uff0c\u4f7f\u7528\u4e86PyTorch\u5e93\uff1a<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\">\n<p><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_7\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">import torch  \r\nimport torch.nn as nn  \r\nimport torch.optim as optim  \r\n  \r\n# \u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u7b80\u5355\u7684Diffusion\u6a21\u578b  \r\nclass DiffusionModel(nn.Module):  \r\n    def __init__(self, input_dim, hidden_dim, num_timesteps):  \r\n        super(DiffusionModel, self).__init__()  \r\n        self.num_timesteps = num_timesteps  \r\n        self.noises = nn.ModuleList([  \r\n            nn.Linear(input_dim, hidden_dim),  \r\n            nn.ReLU(),  \r\n            nn.Linear(hidden_dim, input_dim)  \r\n        ] for _ in range(num_timesteps))  \r\n  \r\n    def forward(self, x, t):  \r\n        noise_prediction = self.noises[t](x)  \r\n        return noise_prediction  \r\n  \r\n# \u8bbe\u7f6e\u6a21\u578b\u53c2\u6570  \r\ninput_dim = 784  # \u5047\u8bbe\u8f93\u5165\u662f28x28\u7684\u7070\u5ea6\u56fe\u50cf  \r\nhidden_dim = 128  \r\nnum_timesteps = 1000  \r\n  \r\n# \u521d\u59cb\u5316\u6a21\u578b  \r\nmodel = DiffusionModel(input_dim, hidden_dim, num_timesteps)  \r\n  \r\n# \u5b9a\u4e49\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u5668  \r\ncriterion = nn.MSELoss()  \r\noptimizer = optim.Adam(model.parameters(), lr=1e-3)<\/code><\/pre>\n<ul id=\"code_id_7\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<li>20.<\/li>\n<li>21.<\/li>\n<li>22.<\/li>\n<li>23.<\/li>\n<li>24.<\/li>\n<li>25.<\/li>\n<li>26.<\/li>\n<li>27.<\/li>\n<li>28.<\/li>\n<li>29.<\/li>\n<li>30.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h4>9.\u56fe\u795e\u7ecf\u7f51\u7edc(GNN)<\/h4>\n<p>\u56fe\u795e\u7ecf\u7f51\u7edc(Graph Neural Networks\uff0c\u7b80\u79f0GNN)\u662f\u4e00\u79cd\u4e13\u95e8\u7528\u4e8e\u5904\u7406\u56fe\u7ed3\u6784\u6570\u636e\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u3002\u5728\u73b0\u5b9e\u4e16\u754c\u4e2d\uff0c\u8bb8\u591a\u590d\u6742\u7cfb\u7edf\u90fd\u53ef\u4ee5\u7528\u56fe\u6765\u8868\u793a\uff0c\u4f8b\u5982\u793e\u4ea4\u7f51\u7edc\u3001\u5206\u5b50\u7ed3\u6784\u3001\u4ea4\u901a\u7f51\u7edc\u7b49\u3002\u4f20\u7edf\u7684\u673a\u5668\u5b66\u4e60\u6a21\u578b\u5728\u5904\u7406\u8fd9\u4e9b\u56fe\u7ed3\u6784\u6570\u636e\u65f6\u9762\u4e34\u8bf8\u591a\u6311\u6218\uff0c\u800c\u56fe\u795e\u7ecf\u7f51\u7edc\u5219\u4e3a\u8fd9\u4e9b\u95ee\u9898\u7684\u89e3\u51b3\u63d0\u4f9b\u4e86\u65b0\u7684\u601d\u8def\u3002<\/p>\n<p><img data-dominant-color=\"e4dfd9\" data-has-transparency=\"false\" style=\"--dominant-color: #e4dfd9;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent alignnone size-full wp-image-19580\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/f9a8cae001d4961ed282855a2b2ad2b7a1bb38-1.png\" width=\"1080\" height=\"646\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/f9a8cae001d4961ed282855a2b2ad2b7a1bb38-1.png 1080w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/f9a8cae001d4961ed282855a2b2ad2b7a1bb38-1-300x179.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/f9a8cae001d4961ed282855a2b2ad2b7a1bb38-1-1024x613.png 1024w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/f9a8cae001d4961ed282855a2b2ad2b7a1bb38-1-150x90.png 150w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/f9a8cae001d4961ed282855a2b2ad2b7a1bb38-1-768x459.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<p>\u6a21\u578b\u539f\u7406\uff1a<\/p>\n<p>\u56fe\u795e\u7ecf\u7f51\u7edc\u7684\u6838\u5fc3\u601d\u60f3\u662f\u901a\u8fc7\u795e\u7ecf\u7f51\u7edc\u5bf9\u56fe\u4e2d\u7684\u8282\u70b9\u8fdb\u884c\u7279\u5f81\u8868\u793a\u5b66\u4e60\uff0c\u540c\u65f6\u8003\u8651\u8282\u70b9\u95f4\u7684\u5173\u7cfb\u3002\u5177\u4f53\u6765\u8bf4\uff0cGNN\u901a\u8fc7\u8fed\u4ee3\u5730\u4f20\u9012\u90bb\u5c45\u4fe1\u606f\u6765\u66f4\u65b0\u8282\u70b9\u7684\u8868\u793a\uff0c\u4f7f\u5f97\u76f8\u540c\u7684\u793e\u533a\u6216\u76f8\u8fd1\u7684\u8282\u70b9\u5177\u6709\u76f8\u8fd1\u7684\u8868\u793a\u3002\u5728\u6bcf\u4e00\u5c42\uff0c\u8282\u70b9\u4f1a\u6839\u636e\u5176\u90bb\u5c45\u8282\u70b9\u7684\u4fe1\u606f\u6765\u66f4\u65b0\u81ea\u5df1\u7684\u8868\u793a\uff0c\u4ece\u800c\u6355\u6349\u5230\u56fe\u4e2d\u7684\u590d\u6742\u6a21\u5f0f\u3002<\/p>\n<p>\u6a21\u578b\u8bad\u7ec3\uff1a<\/p>\n<p>\u8bad\u7ec3\u56fe\u795e\u7ecf\u7f51\u7edc\u901a\u5e38\u91c7\u7528\u57fa\u4e8e\u68af\u5ea6\u7684\u4f18\u5316\u7b97\u6cd5\uff0c\u5982\u968f\u673a\u68af\u5ea6\u4e0b\u964d(SGD)\u3002\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u901a\u8fc7\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\u8ba1\u7b97\u635f\u5931\u51fd\u6570\u7684\u68af\u5ea6\uff0c\u5e76\u66f4\u65b0\u795e\u7ecf\u7f51\u7edc\u7684\u6743\u91cd\u3002\u5e38\u7528\u7684\u635f\u5931\u51fd\u6570\u5305\u62ec\u8282\u70b9\u5206\u7c7b\u7684\u4ea4\u53c9\u71b5\u635f\u5931\u3001\u94fe\u63a5\u9884\u6d4b\u7684\u4e8c\u5143\u4ea4\u53c9\u71b5\u635f\u5931\u7b49\u3002<\/p>\n<p>\u4f18\u70b9\uff1a<\/p>\n<ul data-id=\"u738a58b-EIFmmndi\">\n<li data-id=\"ld70c578-umILgY6G\">\u5f3a\u5927\u7684\u8868\u793a\u80fd\u529b\uff1a\u56fe\u795e\u7ecf\u7f51\u7edc\u80fd\u591f\u6709\u6548\u5730\u6355\u6349\u56fe\u7ed3\u6784\u4e2d\u7684\u590d\u6742\u6a21\u5f0f\uff0c\u4ece\u800c\u5728\u8282\u70b9\u5206\u7c7b\u3001\u94fe\u63a5\u9884\u6d4b\u7b49\u4efb\u52a1\u4e0a\u53d6\u5f97\u8f83\u597d\u7684\u6548\u679c\u3002<\/li>\n<li data-id=\"ld70c578-vAVie7sI\">\u81ea\u7136\u5904\u7406\u56fe\u7ed3\u6784\u6570\u636e\uff1a\u56fe\u795e\u7ecf\u7f51\u7edc\u76f4\u63a5\u5bf9\u56fe\u7ed3\u6784\u6570\u636e\u8fdb\u884c\u5904\u7406\uff0c\u4e0d\u9700\u8981\u5c06\u56fe\u8f6c\u6362\u4e3a\u77e9\u9635\u5f62\u5f0f\uff0c\u4ece\u800c\u907f\u514d\u4e86\u5927\u89c4\u6a21\u7a00\u758f\u77e9\u9635\u5e26\u6765\u7684\u8ba1\u7b97\u548c\u5b58\u50a8\u5f00\u9500\u3002<\/li>\n<li data-id=\"ld70c578-xE9vab2R\">\u53ef\u6269\u5c55\u6027\u5f3a\uff1a\u56fe\u795e\u7ecf\u7f51\u7edc\u53ef\u4ee5\u901a\u8fc7\u5806\u53e0\u66f4\u591a\u7684\u5c42\u6765\u6355\u83b7\u66f4\u590d\u6742\u7684\u6a21\u5f0f\uff0c\u5177\u6709\u5f88\u5f3a\u7684\u53ef\u6269\u5c55\u6027\u3002<\/li>\n<\/ul>\n<p>\u7f3a\u70b9\uff1a<\/p>\n<ul data-id=\"u738a58b-01TGKVmJ\">\n<li data-id=\"ld70c578-V6S4AAiB\">\u8ba1\u7b97\u590d\u6742\u5ea6\u9ad8\uff1a\u968f\u7740\u56fe\u4e2d\u8282\u70b9\u548c\u8fb9\u7684\u589e\u591a\uff0c\u56fe\u795e\u7ecf\u7f51\u7edc\u7684\u8ba1\u7b97\u590d\u6742\u5ea6\u4e5f\u4f1a\u6025\u5267\u589e\u52a0\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u8bad\u7ec3\u65f6\u95f4\u8f83\u957f\u3002<\/li>\n<li data-id=\"ld70c578-48K569lO\">\u53c2\u6570\u8c03\u6574\u56f0\u96be\uff1a\u56fe\u795e\u7ecf\u7f51\u7edc\u7684\u8d85\u53c2\u6570\u8f83\u591a\uff0c\u5982\u90bb\u57df\u5927\u5c0f\u3001\u5c42\u6570\u3001\u5b66\u4e60\u7387\u7b49\uff0c\u8c03\u6574\u8fd9\u4e9b\u53c2\u6570\u53ef\u80fd\u9700\u8981\u5bf9\u4efb\u52a1\u6709\u6df1\u5165\u7684\u7406\u89e3\u3002<\/li>\n<li data-id=\"ld70c578-ZwoohpDv\">\u5bf9\u65e0\u5411\u56fe\u548c\u6709\u5411\u56fe\u7684\u9002\u5e94\u6027\u4e0d\u540c\uff1a\u56fe\u795e\u7ecf\u7f51\u7edc\u6700\u521d\u662f\u4e3a\u65e0\u5411\u56fe\u8bbe\u8ba1\u7684\uff0c\u5bf9\u4e8e\u6709\u5411\u56fe\u7684\u9002\u5e94\u6027\u53ef\u80fd\u8f83\u5dee\u3002<\/li>\n<\/ul>\n<p>\u4f7f\u7528\u573a\u666f\uff1a<\/p>\n<ul data-id=\"u738a58b-8VaKRA6D\">\n<li data-id=\"ld70c578-1WccbSE4\">\u793e\u4ea4\u7f51\u7edc\u5206\u6790\uff1a\u5728\u793e\u4ea4\u7f51\u7edc\u4e2d\uff0c\u7528\u6237\u4e4b\u95f4\u7684\u5173\u7cfb\u53ef\u4ee5\u7528\u56fe\u6765\u8868\u793a\u3002\u901a\u8fc7\u56fe\u795e\u7ecf\u7f51\u7edc\u53ef\u4ee5\u5206\u6790\u7528\u6237\u4e4b\u95f4\u7684\u76f8\u4f3c\u6027\u3001\u793e\u533a\u53d1\u73b0\u3001\u5f71\u54cd\u529b\u4f20\u64ad\u7b49\u95ee\u9898\u3002<\/li>\n<li data-id=\"ld70c578-h2qW6VRf\">\u5206\u5b50\u7ed3\u6784\u9884\u6d4b\uff1a\u5728\u5316\u5b66\u9886\u57df\uff0c\u5206\u5b50\u7684\u7ed3\u6784\u53ef\u4ee5\u7528\u56fe\u6765\u8868\u793a\u3002\u901a\u8fc7\u8bad\u7ec3\u56fe\u795e\u7ecf\u7f51\u7edc\u53ef\u4ee5\u9884\u6d4b\u5206\u5b50\u7684\u6027\u8d28\u3001\u5316\u5b66\u53cd\u5e94\u7b49\u3002<\/li>\n<li data-id=\"ld70c578-mH022Ytx\">\u63a8\u8350\u7cfb\u7edf\uff1a\u63a8\u8350\u7cfb\u7edf\u53ef\u4ee5\u5229\u7528\u7528\u6237\u7684\u884c\u4e3a\u6570\u636e\u6784\u5efa\u56fe\uff0c\u7136\u540e\u4f7f\u7528\u56fe\u795e\u7ecf\u7f51\u7edc\u6765\u6355\u6349\u7528\u6237\u7684\u884c\u4e3a\u6a21\u5f0f\uff0c\u4ece\u800c\u8fdb\u884c\u7cbe\u51c6\u63a8\u8350\u3002<\/li>\n<li data-id=\"ld70c578-pcbCxZJL\">\u77e5\u8bc6\u56fe\u8c31\uff1a\u77e5\u8bc6\u56fe\u8c31\u53ef\u4ee5\u770b\u4f5c\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u56fe\u7ed3\u6784\u6570\u636e\uff0c\u901a\u8fc7\u56fe\u795e\u7ecf\u7f51\u7edc\u53ef\u4ee5\u5bf9\u77e5\u8bc6\u56fe\u8c31\u4e2d\u7684\u5b9e\u4f53\u548c\u5173\u7cfb\u8fdb\u884c\u6df1\u5165\u5206\u6790\u3002<\/li>\n<\/ul>\n<p>\u7b80\u5355\u7684Python\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\">\n<p><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_8\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">import torch  \r\nfrom torch_geometric.datasets import Planetoid  \r\nfrom torch_geometric.nn import GCNConv  \r\nfrom torch_geometric.data import DataLoader  \r\nimport time  \r\n\r\n# \u52a0\u8f7dCora\u6570\u636e\u96c6  \r\ndataset = Planetoid(root='\/tmp\/Cora', name='Cora')  \r\n\r\n# \u5b9a\u4e49GNN\u6a21\u578b  \r\nclass GNN(torch.nn.Module):\r\ndef __init__(self, in_channels, hidden_channels, out_channels):\r\n        super(GNN, self).__init__()  \r\n        self.conv1 = GCNConv(in_channels, hidden_channels)  \r\n        self.conv2 = GCNConv(hidden_channels, out_channels)  \r\n\r\ndef forward(self, data):\r\n        x, edge_index = data.x, data.edge_index  \r\n        x = self.conv1(x, edge_index)  \r\n        x = F.relu(x)  \r\n        x = F.dropout(x, training=self.training)  \r\n        x = self.conv2(x, edge_index)  \r\nreturn F.log_softmax(x, dim=1)  \r\n\r\n# \u5b9a\u4e49\u8d85\u53c2\u6570\u548c\u6a21\u578b\u8bad\u7ec3\u8fc7\u7a0b  \r\nnum_epochs = 1000\r\nlr = 0.01\r\nhidden_channels = 16\r\nout_channels = dataset.num_classes  \r\ndata = dataset[0]  # \u4f7f\u7528\u6570\u636e\u96c6\u4e2d\u7684\u7b2c\u4e00\u4e2a\u6570\u636e\u4f5c\u4e3a\u793a\u4f8b\u6570\u636e  \r\nmodel = GNN(dataset.num_features, hidden_channels, out_channels)  \r\noptimizer = torch.optim.Adam(model.parameters(), lr=lr)  \r\ndata = DataLoader([data], batch_size=1)  # \u5c06\u6570\u636e\u96c6\u8f6c\u6362\u4e3aDataLoader\u5bf9\u8c61\uff0c\u4ee5\u652f\u6301\u6279\u91cf\u8bad\u7ec3\u548c\u8bc4\u4f30  \r\nmodel.train()  # \u8bbe\u7f6e\u6a21\u578b\u4e3a\u8bad\u7ec3\u6a21\u5f0f  \r\nfor epoch in range(num_epochs):  \r\nfor data in data:  # \u5728\u6bcf\u4e2aepoch\u4e2d\u904d\u5386\u6574\u4e2a\u6570\u636e\u96c6\u4e00\u6b21  \r\n        optimizer.zero_grad()  # \u6e05\u96f6\u68af\u5ea6  \r\n        out = model(data)  # \u524d\u5411\u4f20\u64ad\uff0c\u8ba1\u7b97\u8f93\u51fa\u548c\u635f\u5931\u51fd\u6570\u503c  \r\n        loss = F.nll_loss(out[data.train_mask], data.y[data.train_mask])  # \u8ba1\u7b97\u635f\u5931\u51fd\u6570\u503c\uff0c\u8fd9\u91cc\u4f7f\u7528\u8d1f\u5bf9\u6570\u4f3c\u7136\u635f\u5931\u51fd\u6570\u4f5c\u4e3a\u793a\u4f8b\u635f\u5931\u51fd\u6570  \r\n        loss.backward()  # \u53cd\u5411\u4f20\u64ad\uff0c\u8ba1\u7b97\u68af\u5ea6  \r\n        optimizer.step()  # \u66f4\u65b0\u6743\u91cd\u53c2\u6570<\/code><\/pre>\n<ul id=\"code_id_8\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<li>20.<\/li>\n<li>21.<\/li>\n<li>22.<\/li>\n<li>23.<\/li>\n<li>24.<\/li>\n<li>25.<\/li>\n<li>26.<\/li>\n<li>27.<\/li>\n<li>28.<\/li>\n<li>29.<\/li>\n<li>30.<\/li>\n<li>31.<\/li>\n<li>32.<\/li>\n<li>33.<\/li>\n<li>34.<\/li>\n<li>35.<\/li>\n<li>36.<\/li>\n<li>37.<\/li>\n<li>38.<\/li>\n<li>39.<\/li>\n<li>40.<\/li>\n<li>41.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h4>10\u3001\u6df1\u5ea6Q\u7f51\u7edc(DQN)<\/h4>\n<p>\u5728\u4f20\u7edf\u7684\u5f3a\u5316\u5b66\u4e60\u7b97\u6cd5\u4e2d\uff0c\u667a\u80fd\u4f53\u4f7f\u7528\u4e00\u4e2aQ\u8868\u6765\u5b58\u50a8\u72b6\u6001-\u52a8\u4f5c\u503c\u51fd\u6570\u7684\u4f30\u8ba1\u3002\u7136\u800c\uff0c\u8fd9\u79cd\u65b9\u6cd5\u5728\u5904\u7406\u9ad8\u7ef4\u5ea6\u72b6\u6001\u548c\u52a8\u4f5c\u7a7a\u95f4\u65f6\u9047\u5230\u9650\u5236\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cDQN\u662f\u79cd\u6df1\u5ea6\u5f3a\u5316\u5b66\u4e60\u7b97\u6cd5\uff0c\u5f15\u5165\u4e86\u6df1\u5ea6\u5b66\u4e60\u6280\u672f\u6765\u5b66\u4e60\u72b6\u6001-\u52a8\u4f5c\u503c\u51fd\u6570\u7684\u903c\u8fd1\uff0c\u4ece\u800c\u80fd\u591f\u5904\u7406\u66f4\u590d\u6742\u7684\u95ee\u9898\u3002<\/p>\n<p><img data-dominant-color=\"e8e6e5\" data-has-transparency=\"false\" style=\"--dominant-color: #e8e6e5;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent alignnone size-full wp-image-19581\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/e24537321eaa405678d707f254115e51c295d2-1.png\" width=\"474\" height=\"323\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/e24537321eaa405678d707f254115e51c295d2-1.png 474w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/e24537321eaa405678d707f254115e51c295d2-1-300x204.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/03\/e24537321eaa405678d707f254115e51c295d2-1-150x102.png 150w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/p>\n<p>\u6a21\u578b\u539f\u7406\uff1a<\/p>\n<p>DQN\u4f7f\u7528\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc(\u79f0\u4e3a\u6df1\u5ea6Q\u7f51\u7edc)\u6765\u903c\u8fd1\u72b6\u6001-\u52a8\u4f5c\u503c\u51fd\u6570\u3002\u8be5\u795e\u7ecf\u7f51\u7edc\u63a5\u53d7\u5f53\u524d\u72b6\u6001\u4f5c\u4e3a\u8f93\u5165\uff0c\u5e76\u8f93\u51fa\u6bcf\u4e2a\u52a8\u4f5c\u7684Q\u503c\u3002\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u667a\u80fd\u4f53\u901a\u8fc7\u4e0d\u65ad\u4e0e\u73af\u5883\u4ea4\u4e92\u6765\u66f4\u65b0\u795e\u7ecf\u7f51\u7edc\u7684\u6743\u91cd\uff0c\u4ee5\u9010\u6e10\u903c\u8fd1\u6700\u4f18\u7684Q\u503c\u51fd\u6570\u3002<\/p>\n<p>\u6a21\u578b\u8bad\u7ec3\uff1a<\/p>\n<p>DQN\u7684\u8bad\u7ec3\u8fc7\u7a0b\u5305\u62ec\u4e24\u4e2a\u9636\u6bb5\uff1a\u79bb\u7ebf\u9636\u6bb5\u548c\u5728\u7ebf\u9636\u6bb5\u3002\u5728\u79bb\u7ebf\u9636\u6bb5\uff0c\u667a\u80fd\u4f53\u4ece\u7ecf\u9a8c\u56de\u653e\u7f13\u51b2\u533a\u4e2d\u968f\u673a\u91c7\u6837\u4e00\u6279\u7ecf\u9a8c(\u5373\u72b6\u6001\u3001\u52a8\u4f5c\u3001\u5956\u52b1\u548c\u4e0b\u4e00\u4e2a\u72b6\u6001)\uff0c\u5e76\u4f7f\u7528\u8fd9\u4e9b\u7ecf\u9a8c\u6765\u66f4\u65b0\u6df1\u5ea6Q\u7f51\u7edc\u3002\u5728\u7ebf\u9636\u6bb5\uff0c\u667a\u80fd\u4f53\u4f7f\u7528\u5f53\u524d\u7684\u72b6\u6001\u548c\u6df1\u5ea6Q\u7f51\u7edc\u6765\u9009\u62e9\u548c\u6267\u884c\u6700\u4f73\u7684\u884c\u52a8\uff0c\u5e76\u5c06\u65b0\u7684\u7ecf\u9a8c\u5b58\u50a8\u5728\u7ecf\u9a8c\u56de\u653e\u7f13\u51b2\u533a\u4e2d\u3002<\/p>\n<p>\u4f18\u70b9\uff1a<\/p>\n<ul data-id=\"u738a58b-dX5atdsf\">\n<li data-id=\"ld70c578-bBZGwqb0\">\u5904\u7406\u9ad8\u7ef4\u5ea6\u72b6\u6001\u548c\u52a8\u4f5c\u7a7a\u95f4\uff1aDQN\u80fd\u591f\u5904\u7406\u5177\u6709\u9ad8\u7ef4\u5ea6\u72b6\u6001\u548c\u52a8\u4f5c\u7a7a\u95f4\u7684\u590d\u6742\u95ee\u9898\uff0c\u8fd9\u4f7f\u5f97\u5b83\u5728\u8bb8\u591a\u9886\u57df\u4e2d\u5177\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u3002<\/li>\n<li data-id=\"ld70c578-6nKM2mef\">\u51cf\u5c11\u6570\u636e\u4f9d\u8d56\u6027\uff1a\u901a\u8fc7\u4f7f\u7528\u7ecf\u9a8c\u56de\u653e\u7f13\u51b2\u533a\uff0cDQN\u53ef\u4ee5\u5728\u6709\u9650\u7684\u6837\u672c\u4e0b\u8fdb\u884c\u6709\u6548\u7684\u8bad\u7ec3\u3002<\/li>\n<li data-id=\"ld70c578-QNkQLPM8\">\u7075\u6d3b\u6027\uff1aDQN\u53ef\u4ee5\u4e0e\u5176\u4ed6\u5f3a\u5316\u5b66\u4e60\u7b97\u6cd5\u548c\u6280\u672f\u7ed3\u5408\u4f7f\u7528\uff0c\u4ee5\u8fdb\u4e00\u6b65\u63d0\u9ad8\u6027\u80fd\u548c\u6269\u5c55\u5176\u5e94\u7528\u8303\u56f4\u3002<\/li>\n<\/ul>\n<p>\u7f3a\u70b9\uff1a<\/p>\n<ul data-id=\"u738a58b-8UtmYSGB\">\n<li data-id=\"ld70c578-H5mA9h49\">\u4e0d\u7a33\u5b9a\u8bad\u7ec3\uff1a\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0cDQN\u7684\u8bad\u7ec3\u53ef\u80fd\u4f1a\u4e0d\u7a33\u5b9a\uff0c\u5bfc\u81f4\u5b66\u4e60\u8fc7\u7a0b\u5931\u8d25\u6216\u6027\u80fd\u4e0b\u964d\u3002<\/li>\n<li data-id=\"ld70c578-KSBQjSbo\">\u63a2\u7d22\u7b56\u7565\uff1aDQN\u9700\u8981\u4e00\u4e2a\u6709\u6548\u7684\u63a2\u7d22\u7b56\u7565\u6765\u63a2\u7d22\u73af\u5883\u5e76\u6536\u96c6\u8db3\u591f\u7684\u7ecf\u9a8c\u3002\u9009\u62e9\u5408\u9002\u7684\u63a2\u7d22\u7b56\u7565\u662f\u5173\u952e\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5f71\u54cd\u5b66\u4e60\u901f\u5ea6\u548c\u6700\u7ec8\u7684\u6027\u80fd\u3002<\/li>\n<li data-id=\"ld70c578-lU4E6530\">\u5bf9\u76ee\u6807\u7f51\u7edc\u7684\u9700\u6c42\uff1a\u4e3a\u4e86\u7a33\u5b9a\u8bad\u7ec3\uff0cDQN\u901a\u5e38\u9700\u8981\u4f7f\u7528\u76ee\u6807\u7f51\u7edc\u6765\u66f4\u65b0Q\u503c\u51fd\u6570\u3002\u8fd9\u589e\u52a0\u4e86\u7b97\u6cd5\u7684\u590d\u6742\u6027\u5e76\u9700\u8981\u989d\u5916\u7684\u53c2\u6570\u8c03\u6574\u3002<\/li>\n<\/ul>\n<p>\u4f7f\u7528\u573a\u666f\uff1a<\/p>\n<p>DQN\u5df2\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u6e38\u620fAI\u4efb\u52a1\uff0c\u5982\u56f4\u68cb\u3001\u7eb8\u724c\u6e38\u620f\u7b49\u3002\u6b64\u5916\uff0c\u5b83\u8fd8\u88ab\u5e94\u7528\u4e8e\u5176\u4ed6\u9886\u57df\uff0c\u5982\u673a\u5668\u4eba\u63a7\u5236\u3001\u81ea\u7136\u8bed\u8a00\u5904\u7406\u548c\u81ea\u52a8\u9a7e\u9a76\u7b49\u3002<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\">\n<p><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_9\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">python\r\nimport numpy as np  \r\nimport tensorflow as tf  \r\nfrom tensorflow.keras.models import Sequential  \r\nfrom tensorflow.keras.layers import Dense, Dropout  \r\nclass DQN:  \r\ndef __init__(self, state_size, action_size):  \r\nself.state_size = state_size  \r\nself.action_size = action_size  \r\nself.memory = np.zeros((MEM_CAPACITY, state_size * 2 + 2))  \r\nself.gamma = 0.95\r\nself.epsilon = 1.0\r\nself.epsilon_min = 0.01\r\nself.epsilon_decay = 0.995\r\nself.learning_rate = 0.005\r\nself.model = self.create_model()  \r\ndef create_model(self):  \r\n        model = Sequential()  \r\n        model.add(Dense(24, input_dim=self.state_size, activation='relu'))  \r\n        model.add(Dense(24, activation='relu'))  \r\n        model.add(Dense(self.action_size, activation='linear'))  \r\n        model.compile(loss='mse', optimizer=tf.keras.optimizers.Adam(lr=self.learning_rate))  \r\nreturn model  \r\ndef remember(self, state, action, reward, next_state, done):  \r\nself.memory[self.memory_counter % MEM_CAPACITY, :] = [state, action, reward, next_state, done]  \r\nself.memory_counter += 1\r\ndef act(self, state):  \r\nif np.random.rand() &lt;= self.epsilon:\r\nreturn np.random.randint(self.action_size)  \r\n        act_values = self.model.predict(state)  \r\nreturn np.argmax(act_values[0])  \r\ndef replay(self):  \r\n        batch_size = 32\r\n        start = np.random.randint(0, self.memory_counter - batch_size, batch_size)  \r\n        sample = self.memory[start:start + batch_size]  \r\n        states = np.array([s[0] for s in sample])  \r\n        actions = np.array([s[1] for s in sample])  \r\n        rewards = np.array([s[2] for s in sample])  \r\n        next_states = np.array([s[3] for s in sample])  \r\n        done = np.array([s[4] for s in sample])  \r\n        target = self.model.predict(next_states)  \r\n        target_q = rewards + (1 - done) * self.gamma * np.max(target, axis=1)  \r\n        target_q = np.asarray([target_q[i] for i in range(batch_size)])  \r\n        target = self.model.predict(states)  \r\n        indices = np.arange(batch_size)  \r\nfor i in range(batch_size):  \r\nif done[i]: continue  # no GAE calc for terminal states (if you want to include terminal states see line 84)  \r\n            target[indices[i]] = rewards[i] + self.gamma * target_q[indices[i]]  # GAE formula line 84 (https:\/\/arxiv.org\/pdf\/1506.02438v5) instead of line 85 (https:\/\/arxiv.org\/pdf\/1506.02438v5) (if you want to include terminal states see line 84)  \r\n            indices[i] += batch_size  # resets the indices for the next iteration (https:\/\/github.com\/ikostrikov\/pytorch-a2c-ppo-acktr-gail\/blob\/master\/a2c.py#L173) (if you want to include terminal states see line 84)  \r\n            target[indices[i]] = target[indices[i]]  # resets the indices for the next iteration (https:\/\/github.com\/ikostrikov\/pytorch-a2c-ppo-acktr-gail\/blob\/master\/a2c.py#L173) (if you want to include terminal states see line 84) (https:\/\/github.com\/ikostrikov\/pytorch-a2c-ppo-acktr-gail\/blob\/master\/a2c.py#L173)<\/code><\/pre>\n<ul id=\"code_id_9\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<li>20.<\/li>\n<li>21.<\/li>\n<li>22.<\/li>\n<li>23.<\/li>\n<li>24.<\/li>\n<li>25.<\/li>\n<li>26.<\/li>\n<li>27.<\/li>\n<li>28.<\/li>\n<li>29.<\/li>\n<li>30.<\/li>\n<li>31.<\/li>\n<li>32.<\/li>\n<li>33.<\/li>\n<li>34.<\/li>\n<li>35.<\/li>\n<li>36.<\/li>\n<li>37.<\/li>\n<li>38.<\/li>\n<li>39.<\/li>\n<li>40.<\/li>\n<li>41.<\/li>\n<li>42.<\/li>\n<li>43.<\/li>\n<li>44.<\/li>\n<li>45.<\/li>\n<li>46.<\/li>\n<li>47.<\/li>\n<li>48.<\/li>\n<li>49.<\/li>\n<li>50.<\/li>\n<\/ul>\n<p>\u6587\u7ae0\u6765\u81ea\uff1a51CTO<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_19557\" class=\"pvc_stats total_only  \" data-element-id=\"19557\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.0\" viewBox=\"0 0 502 315\" preserveAspectRatio=\"xMidYMid meet\"><g transform=\"translate(0,332) scale(0.1,-0.1)\" fill=\"\" stroke=\"none\"><path d=\"M2394 3279 l-29 -30 -3 -207 c-2 -182 0 -211 15 -242 39 -76 157 -76 196 0 15 31 17 60 15 243 l-3 209 -33 29 c-26 23 -41 29 -80 29 -41 0 -53 -5 -78 -31z\"\/><path d=\"M3085 3251 c-45 -19 -58 -50 -96 -229 -47 -217 -49 -260 -13 -295 52 -53 146 -42 177 20 16 31 87 366 87 410 0 70 -86 122 -155 94z\"\/><path d=\"M1751 3234 c-13 -9 -29 -31 -37 -50 -12 -29 -10 -49 21 -204 19 -94 39 -189 45 -210 14 -50 54 -80 110 -80 34 0 48 6 76 34 21 21 34 44 34 59 0 14 -18 113 -40 219 -37 178 -43 195 -70 221 -36 32 -101 37 -139 11z\"\/><path d=\"M1163 3073 c-36 -7 -73 -59 -73 -102 0 -56 133 -378 171 -413 34 -32 83 -37 129 -13 70 36 67 87 -16 290 -86 209 -89 214 -129 231 -35 14 -42 15 -82 7z\"\/><path d=\"M3689 3066 c-15 -9 -33 -30 -42 -48 -48 -103 -147 -355 -147 -375 0 -98 131 -148 192 -74 13 15 57 108 97 206 80 196 84 226 37 273 -30 30 -99 39 -137 18z\"\/><path d=\"M583 2784 c-38 -19 -67 -74 -58 -113 9 -42 211 -354 242 -373 16 -10 45 -18 66 -18 51 0 107 52 107 100 0 39 -1 41 -124 234 -80 126 -108 162 -133 173 -41 17 -61 16 -100 -3z\"\/><path d=\"M4250 2784 c-14 -9 -74 -91 -133 -183 -95 -150 -107 -173 -107 -213 0 -55 33 -94 87 -104 67 -13 90 8 211 198 130 202 137 225 78 284 -27 27 -42 34 -72 34 -22 0 -50 -8 -64 -16z\"\/><path d=\"M2275 2693 c-553 -48 -1095 -270 -1585 -649 -135 -104 -459 -423 -483 -476 -23 -49 -22 -139 2 -186 73 -142 361 -457 571 -626 285 -228 642 -407 990 -497 242 -63 336 -73 660 -74 310 0 370 5 595 52 535 111 1045 392 1455 803 122 121 250 273 275 326 19 41 19 137 0 174 -41 79 -309 363 -465 492 -447 370 -946 591 -1479 653 -113 14 -422 18 -536 8z m395 -428 c171 -34 330 -124 456 -258 112 -119 167 -219 211 -378 27 -96 24 -300 -5 -401 -72 -255 -236 -447 -474 -557 -132 -62 -201 -76 -368 -76 -167 0 -236 14 -368 76 -213 98 -373 271 -451 485 -162 444 86 934 547 1084 153 49 292 57 452 25z m909 -232 c222 -123 408 -262 593 -441 76 -74 138 -139 138 -144 0 -16 -233 -242 -330 -319 -155 -123 -309 -223 -461 -299 l-81 -41 32 46 c18 26 49 83 70 128 143 306 141 649 -6 957 -25 52 -61 116 -79 142 l-34 47 45 -20 c26 -10 76 -36 113 -56z m-2057 25 c-40 -58 -105 -190 -130 -263 -110 -324 -59 -707 132 -981 25 -35 42 -64 37 -64 -19 0 -241 119 -326 174 -188 122 -406 314 -532 468 l-58 71 108 103 c185 178 428 349 672 473 66 33 121 60 123 61 2 0 -10 -19 -26 -42z\"\/><path d=\"M2375 1950 c-198 -44 -350 -190 -395 -379 -18 -76 -8 -221 19 -290 114 -284 457 -406 731 -260 98 52 188 154 231 260 27 69 37 214 19 290 -38 163 -166 304 -326 360 -67 23 -215 33 -279 19z\"\/><\/g><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/aif.amtbbs.org\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea2006\u5e74\u6df1\u5ea6\u5b66\u4e60\u6982\u5ff5\u88ab\u63d0\u51fa\u4ee5\u6765\uff0c20\u5e74\u5feb\u8fc7\u53bb\u4e86\uff0c\u6df1\u5ea6\u5b66\u4e60\u4f5c\u4e3a\u4eba\u5de5\u667a\u80fd\u9886\u57df\u7684\u4e00\u573a\u9769\u547d\uff0c\u5df2\u7ecf\u50ac\u751f\u4e86\u8bb8\u591a\u5177\u6709\u5f71\u54cd [&hellip;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_19557\" class=\"pvc_stats total_only  \" data-element-id=\"19557\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.0\" viewBox=\"0 0 502 315\" preserveAspectRatio=\"xMidYMid meet\"><g transform=\"translate(0,332) scale(0.1,-0.1)\" fill=\"\" stroke=\"none\"><path d=\"M2394 3279 l-29 -30 -3 -207 c-2 -182 0 -211 15 -242 39 -76 157 -76 196 0 15 31 17 60 15 243 l-3 209 -33 29 c-26 23 -41 29 -80 29 -41 0 -53 -5 -78 -31z\"\/><path d=\"M3085 3251 c-45 -19 -58 -50 -96 -229 -47 -217 -49 -260 -13 -295 52 -53 146 -42 177 20 16 31 87 366 87 410 0 70 -86 122 -155 94z\"\/><path d=\"M1751 3234 c-13 -9 -29 -31 -37 -50 -12 -29 -10 -49 21 -204 19 -94 39 -189 45 -210 14 -50 54 -80 110 -80 34 0 48 6 76 34 21 21 34 44 34 59 0 14 -18 113 -40 219 -37 178 -43 195 -70 221 -36 32 -101 37 -139 11z\"\/><path d=\"M1163 3073 c-36 -7 -73 -59 -73 -102 0 -56 133 -378 171 -413 34 -32 83 -37 129 -13 70 36 67 87 -16 290 -86 209 -89 214 -129 231 -35 14 -42 15 -82 7z\"\/><path d=\"M3689 3066 c-15 -9 -33 -30 -42 -48 -48 -103 -147 -355 -147 -375 0 -98 131 -148 192 -74 13 15 57 108 97 206 80 196 84 226 37 273 -30 30 -99 39 -137 18z\"\/><path d=\"M583 2784 c-38 -19 -67 -74 -58 -113 9 -42 211 -354 242 -373 16 -10 45 -18 66 -18 51 0 107 52 107 100 0 39 -1 41 -124 234 -80 126 -108 162 -133 173 -41 17 -61 16 -100 -3z\"\/><path d=\"M4250 2784 c-14 -9 -74 -91 -133 -183 -95 -150 -107 -173 -107 -213 0 -55 33 -94 87 -104 67 -13 90 8 211 198 130 202 137 225 78 284 -27 27 -42 34 -72 34 -22 0 -50 -8 -64 -16z\"\/><path d=\"M2275 2693 c-553 -48 -1095 -270 -1585 -649 -135 -104 -459 -423 -483 -476 -23 -49 -22 -139 2 -186 73 -142 361 -457 571 -626 285 -228 642 -407 990 -497 242 -63 336 -73 660 -74 310 0 370 5 595 52 535 111 1045 392 1455 803 122 121 250 273 275 326 19 41 19 137 0 174 -41 79 -309 363 -465 492 -447 370 -946 591 -1479 653 -113 14 -422 18 -536 8z m395 -428 c171 -34 330 -124 456 -258 112 -119 167 -219 211 -378 27 -96 24 -300 -5 -401 -72 -255 -236 -447 -474 -557 -132 -62 -201 -76 -368 -76 -167 0 -236 14 -368 76 -213 98 -373 271 -451 485 -162 444 86 934 547 1084 153 49 292 57 452 25z m909 -232 c222 -123 408 -262 593 -441 76 -74 138 -139 138 -144 0 -16 -233 -242 -330 -319 -155 -123 -309 -223 -461 -299 l-81 -41 32 46 c18 26 49 83 70 128 143 306 141 649 -6 957 -25 52 -61 116 -79 142 l-34 47 45 -20 c26 -10 76 -36 113 -56z m-2057 25 c-40 -58 -105 -190 -130 -263 -110 -324 -59 -707 132 -981 25 -35 42 -64 37 -64 -19 0 -241 119 -326 174 -188 122 -406 314 -532 468 l-58 71 108 103 c185 178 428 349 672 473 66 33 121 60 123 61 2 0 -10 -19 -26 -42z\"\/><path d=\"M2375 1950 c-198 -44 -350 -190 -395 -379 -18 -76 -8 -221 19 -290 114 -284 457 -406 731 -260 98 52 188 154 231 260 27 69 37 214 19 290 -38 163 -166 304 -326 360 -67 23 -215 33 -279 19z\"\/><\/g><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/aif.amtbbs.org\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":56,"featured_media":19558,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,23,80],"tags":[1066],"class_list":["post-19557","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","category-23","category-80","tag-1066"],"_links":{"self":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/19557","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/users\/56"}],"replies":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/comments?post=19557"}],"version-history":[{"count":3,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/19557\/revisions"}],"predecessor-version":[{"id":19582,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/19557\/revisions\/19582"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/media\/19558"}],"wp:attachment":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/media?parent=19557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/categories?post=19557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/tags?post=19557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}