{"id":1424,"date":"2024-09-15T07:43:00","date_gmt":"2024-09-14T23:43:00","guid":{"rendered":"https:\/\/blog.laoyulaoyu.top\/?p=1424"},"modified":"2024-09-07T13:48:25","modified_gmt":"2024-09-07T05:48:25","slug":"%e5%9b%be%e7%a5%9e%e7%bb%8f%e8%bf%90%e7%ae%97%e7%ac%a6-%ef%bc%88gno%ef%bc%89%e8%83%bd%e4%b8%8d%e8%83%bd%e7%94%a8%e4%ba%8e%e7%82%92%e8%82%a1%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/laoyulaoyu.com\/index.php\/2024\/09\/15\/%e5%9b%be%e7%a5%9e%e7%bb%8f%e8%bf%90%e7%ae%97%e7%ac%a6-%ef%bc%88gno%ef%bc%89%e8%83%bd%e4%b8%8d%e8%83%bd%e7%94%a8%e4%ba%8e%e7%82%92%e8%82%a1%ef%bc%9f\/","title":{"rendered":"\u56fe\u795e\u7ecf\u8fd0\u7b97\u7b26 \uff08GNO\uff09\u80fd\u4e0d\u80fd\u7528\u4e8e\u7092\u80a1\uff1f"},"content":{"rendered":"\n<p>\u4f5c\u8005\uff1a<a href=\"https:\/\/www.laoyulaoyu.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u8001\u4f59\u635e\u9c7c<\/a><\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002<\/mark><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/1_p0YJ_bYFfRMTCM6Nc8xBnw-1.webp\" alt=\"\" class=\"wp-image-1788\"\/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<pre class=\"wp-block-verse\"><strong>\u5199\u5728\u524d\u9762\u7684\u8bdd\uff1a<\/strong>\u5728\u4e0d\u65ad\u53d1\u5c55\u7684\u673a\u5668\u5b66\u4e60\u548c\u91d1\u878d\u6280\u672f\u9886\u57df\u4e2d\uff0c\u56fe\u795e\u7ecf\u8fd0\u7b97\u7b26 \uff08GNO\uff09 \u5df2\u6210\u4e3a\u5bf9\u590d\u6742\u7cfb\u7edf\u8fdb\u884c\u5efa\u6a21\u7684\u5f3a\u5927\u5de5\u5177\u3002\u8fd9\u7bc7\u535a\u6587\u5c06\u63a2\u8ba8<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u4ec0\u4e48\u662f GNO\u3001\u5b83\u4eec\u7684\u7528\u9014\u4ee5\u53ca\u5982\u4f55\u5c06\u5b83\u4eec\u5e94\u7528\u4e8e\u5177\u6709\u6311\u6218\u6027\u7684\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u4efb\u52a1\u3002<\/mark><\/pre>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001\u56fe\u795e\u7ecf\u8fd0\u7b97\u7b26\u53ca\u5176\u7528\u9014<\/strong><\/h2>\n\n\n\n<p>Graph Neural Operators \u662f Graph Neural Networks \uff08GNN\uff09 \u7684\u6269\u5c55\uff0c\u65e8\u5728\u5b66\u4e60\u548c\u64cd\u4f5c\u56fe\u5f62\u7ed3\u6784\u6570\u636e\u3002\u4f20\u7edf\u7684 GNN \u4f7f\u7528\u56fa\u5b9a\u7684\u56fe\u5f62\u7ed3\u6784\uff0c<strong>\u800c GNO \u53ef\u4ee5\u5904\u7406\u52a8\u6001\u56fe\u5f62\u5e76\u5b66\u4e60\u8fd1\u4f3c\u5728\u56fe\u5f62\u4e0a\u5b9a\u4e49\u7684\u51fd\u6570\u7a7a\u95f4\u4e4b\u95f4\u6620\u5c04\u7684\u590d\u6742\u8fd0\u7b97\u7b26<\/strong>\u3002<\/p>\n\n\n\n<p>GNO \u7684\u4e3b\u8981\u76ee\u7684\u662f\u5bf9\u5b9e\u4f53 \uff08\u8282\u70b9\uff09 \u5177\u6709\u590d\u6742\u3001\u76f8\u4e92\u4f9d\u8d56\u7684\u5173\u7cfb \uff08\u8fb9\uff09 \u7684\u7cfb\u7edf\u4e2d\u7684\u884c\u4e3a\u8fdb\u884c\u5efa\u6a21\u548c\u9884\u6d4b\u3002\u5b83\u4eec\u5728\u4ee5\u4e0b\u573a\u666f\u4e2d\u8868\u73b0\u51fa\u8272\uff1a<\/p>\n\n\n\n<p>1. \u5e95\u5c42\u7cfb\u7edf\u53ef\u4ee5\u7528\u56fe\u8868\u793a\u3002<br>2 \u5b9e\u4f53\u4e4b\u95f4\u7684\u5173\u7cfb\u5bf9\u4e8e\u9884\u6d4b\u975e\u5e38\u91cd\u8981<br>3 \u7cfb\u7edf\u8868\u73b0\u51fa\u975e\u7ebf\u6027\u52a8\u529b\u5b66<\/p>\n\n\n\n<p>GNO \u901a\u8fc7\u5b66\u4e60\u8fd1\u4f3c\u8fde\u7eed\u8fd0\u7b97\u7b26\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff0c\u4f7f\u4ed6\u4eec\u80fd\u591f\u6355\u83b7\u6570\u636e\u4e2d\u590d\u6742\u7684\u6a21\u5f0f\u548c\u4f9d\u8d56\u5173\u7cfb\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e8c\u3001\u4f7f\u7528 GNO \u5bf9\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u8fdb\u884c\u5efa\u6a21<\/strong><\/h2>\n\n\n\n<p>\u80a1\u7968\u5e02\u573a\u662f\u5177\u6709\u76f8\u4e92\u4f9d\u5b58\u5b9e\u4f53\u7684\u590d\u6742\u7cfb\u7edf\u7684\u5178\u578b\u4f8b\u5b50\u3002\u6bcf\u53ea\u80a1\u7968\u90fd\u53ef\u4ee5\u88ab\u89c6\u4e3a\u56fe\u8868\u4e2d\u7684\u4e00\u4e2a\u8282\u70b9\uff0c\u5176\u8fb9\u8868\u793a\u80a1\u7968\u4e4b\u95f4\u7684\u5173\u7cfb\u6216\u76f8\u5173\u6027\u3002\u8fd9\u4e9b\u5173\u7cfb\u662f\u52a8\u6001\u7684\uff0c\u53ef\u80fd\u4f1a\u6839\u636e\u5404\u79cd\u56e0\u7d20\uff08\u5982\u5e02\u573a\u72b6\u51b5\u3001\u516c\u53f8\u7ee9\u6548\u548c\u5168\u7403\u4e8b\u4ef6\uff09\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\u800c\u53d8\u5316\u3002<\/p>\n\n\n\n<p>\u5728\u6211\u4eec\u7684\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u6a21\u578b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 GNO \u6765\u6355\u83b7\u8fd9\u4e9b\u590d\u6742\u7684\u5173\u7cfb\u5e76\u9884\u6d4b\u672a\u6765\u7684\u80a1\u7968\u4ef7\u683c\u3002\u4ee5\u4e0b\u662f\u6211\u4eec\u89e3\u51b3\u95ee\u9898\u7684\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<p>1. <strong>\u6570\u636e\u8868\u793a<\/strong>\uff1a\u6211\u4eec\u4f7f\u7528\u591a\u5bb6\u516c\u53f8\u7684\u5386\u53f2\u80a1\u7968\u4ef7\u683c\u4f5c\u4e3a\u6211\u4eec\u7684\u8f93\u5165\u6570\u636e\u3002\u6bcf\u53ea\u80a1\u7968\u90fd\u662f\u6211\u4eec\u56fe\u4e2d\u7684\u4e00\u4e2a\u8282\u70b9\uff0c\u8fb9\u7f18\u7531\u80a1\u7968\u4ef7\u683c\u4e4b\u95f4\u7684\u76f8\u5173\u6027\u51b3\u5b9a\u3002<\/p>\n\n\n\n<p>2. <strong>\u56fe\u5f62\u6784\u5efa<\/strong>\uff1a\u6211\u4eec\u6839\u636e\u5386\u53f2\u4ef7\u683c\u8d70\u52bf\u8ba1\u7b97\u76f8\u5173\u77e9\u9635\uff0c\u5e76\u4f7f\u7528\u5b83\u6765\u5728\u76f8\u5173\u6027\u9ad8\u4e8e\u7279\u5b9a\u9608\u503c\u7684\u80a1\u7968\u4e4b\u95f4\u521b\u5efa\u8fb9\u7f18\u3002<\/p>\n\n\n\n<p>3. <strong>\u7279\u5f81\u5de5\u7a0b<\/strong>\uff1a\u6bcf\u4e2a\u8282\u70b9\uff08\u80a1\u7968\uff09\u7684\u7279\u5f81\u662f\u8bbe\u5b9a\u65f6\u95f4\u6bb5\u5185\u7684\u5386\u53f2\u4ef7\u683c\u6570\u636e\u3002<\/p>\n\n\n\n<p>4. <strong>\u9884\u6d4b\u4efb\u52a1<\/strong>\uff1a\u6211\u4eec\u7684 GNO \u6a21\u578b\u65e8\u5728\u540c\u65f6\u9884\u6d4b\u6240\u6709\u80a1\u7968\u7684\u7b2c\u4e8c\u5929\u4ef7\u683c\uff0c\u540c\u65f6\u8003\u8651\u5230\u5b83\u4eec\u4e4b\u95f4\u7684\u76f8\u4e92\u4f9d\u8d56\u5173\u7cfb\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.1 \u67b6\u6784\u548c\u6d41\u7a0b<\/strong><\/h3>\n\n\n\n<p>\u6211\u4eec\u7684\u80a1\u7968\u4ef7\u683c\u9884\u6d4b GNO \u6a21\u578b\u9075\u5faa\u4ee5\u4e0b\u4e00\u822c\u67b6\u6784\u548c\u6d41\u7a0b\uff1a<\/p>\n\n\n\n<p>1. \u8f93\u5165\u5c42\uff1a\u8003\u8651\u56fe\u5f62\u7ed3\u6784\uff08\u8282\u70b9\u548c\u8fb9\uff09\u548c\u8282\u70b9\u7279\u5f81\uff08\u5386\u53f2\u4ef7\u683c\uff09\u3002<\/p>\n\n\n\n<p>2. \u56fe\u5377\u79ef\u5c42\uff1a\u5728\u8282\u70b9\u4e4b\u95f4\u6267\u884c\u6d88\u606f\u4f20\u9012\u7684\u591a\u4e2a\u5c42\uff0c\u5141\u8bb8\u4fe1\u606f\u901a\u8fc7\u56fe\u4f20\u64ad\u3002<\/p>\n\n\n\n<p>3. \u5168\u8fde\u63a5\u5c42\uff1a\u5904\u7406\u56fe\u5f62\u5377\u79ef\u7684\u8f93\u51fa\u4ee5\u505a\u51fa\u6700\u7ec8\u9884\u6d4b\u3002<\/p>\n\n\n\n<p>4. \u8f93\u51fa\u5c42\uff1a\u540c\u65f6\u751f\u6210\u6240\u6709\u80a1\u7968\u7684\u9884\u6d4b\u3002<\/p>\n\n\n\n<p><strong>\u901a\u8fc7\u6a21\u578b\u7684\u6570\u636e\u6d41\u5982\u4e0b\u6240\u793a\uff1a<\/strong><br><br>1. \u5386\u53f2\u80a1\u7968\u4ef7\u683c\u6570\u636e\u7ecf\u8fc7\u9884\u5904\u7406\u548c\u89c4\u8303\u5316\u3002<br>2. \u6839\u636e\u80a1\u7968\u4ef7\u683c\u76f8\u5173\u6027\u6784\u5efa\u56fe\u8868\u3002<br>3. \u5c06\u56fe\u5f62\u548c\u8282\u70b9\u7279\u5f81\u9988\u9001\u5230 GNO \u6a21\u578b\u4e2d\u3002<br>4. \u6a21\u578b\u6267\u884c\u591a\u8f6e\u6d88\u606f\u4f20\u9012\u548c\u7279\u5f81\u8f6c\u6362\u3002<br>5. \u6700\u540e\u4e00\u5c42\u751f\u6210\u6240\u6709\u80a1\u7968\u7684\u9884\u6d4b\u3002<br>6. \u5bf9\u9884\u6d4b\u8fdb\u884c\u975e\u89c4\u8303\u5316\u4ee5\u83b7\u5f97\u5b9e\u9645\u7684\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.2 \u4ee3\u7801\u8bf4\u660e<\/strong><\/h3>\n\n\n\n<p>\u8ba9\u6211\u4eec\u5206\u89e3\u4e00\u4e0b\u6211\u4eec\u5b9e\u73b0\u7684\u5173\u952e\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<p><strong>\u6570\u636e\u51c6\u5907\uff1a<\/strong><br>\u6211\u4eec\u9996\u5148\u4f7f\u7528 yfinance \u5e93\u4e0b\u8f7d\u5386\u53f2\u80a1\u7968\u4ef7\u683c\u6570\u636e\u3002\u7136\u540e\u4f7f\u7528 MinMaxScaler \u5bf9\u6570\u636e\u8fdb\u884c\u5f52\u4e00\u5316\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u7279\u5f81\u90fd\u5904\u4e8e\u76f8\u540c\u7684\u6bd4\u4f8b\u4e0a\u3002<\/p>\n\n\n\n<p><strong>\u56fe\u5f62\u6784\u5efa\uff1a<\/strong><br>\u6211\u4eec\u4ece\u6807\u51c6\u5316\u7684\u4ef7\u683c\u6570\u636e\u4e2d\u8ba1\u7b97\u51fa\u4e00\u4e2a\u76f8\u5173\u77e9\u9635\uff0c\u5e76\u4f7f\u7528\u5b83\u6765\u5728\u76f8\u5173\u6027\u9ad8\u4e8e\u67d0\u4e2a\u9608\u503c\u7684\u80a1\u7968\u4e4b\u95f4\u521b\u5efa\u8fb9\u7f18\u3002\u8fd9\u6784\u6210\u4e86\u6211\u4eec\u7684\u56fe\u5f62\u7ed3\u6784\u3002<\/p>\n\n\n\n<p><strong>\u6a21\u578b\u5b9a\u4e49\uff1a<\/strong><br>\u6211\u4eec\u7684 ImprovedGraphNeuralOperator \u7c7b\u5b9a\u4e49\u4e86\u6211\u4eec\u7684 GNO \u7684\u67b6\u6784\u3002\u5b83\u7531\u591a\u4e2a\u56fe\u5f62\u5377\u79ef\u5c42 \uff08GCNConv\uff09 \u548c\u5168\u8fde\u63a5\u5c42\u7ec4\u6210\u3002\u6211\u4eec\u8fd8\u52a0\u5165\u4e86 dropout \u4ee5\u8fdb\u884c\u6b63\u5219\u5316\u3002<\/p>\n\n\n\n<p><strong>\u8bad\u7ec3\u5faa\u73af\uff1a<\/strong><br>\u6a21\u578b\u4f7f\u7528\u5747\u65b9\u8bef\u5dee\u4f5c\u4e3a\u635f\u5931\u51fd\u6570\uff0c\u4f7f\u7528 Adam \u4f5c\u4e3a\u4f18\u5316\u5668\u8fdb\u884c\u8bad\u7ec3\u3002\u6211\u4eec\u904d\u5386\u591a\u4e2a epoch\uff0c\u6267\u884c\u5411\u524d\u548c\u5411\u540e\u4f20\u9012\u4ee5\u66f4\u65b0\u6a21\u578b\u53c2\u6570\u3002<\/p>\n\n\n\n<p><strong>\u9884\u6d4b\u548c\u8bc4\u4f30\uff1a<\/strong><br>\u8bad\u7ec3\u540e\uff0c\u6211\u4eec\u4f7f\u7528\u6a21\u578b\u5bf9\u6574\u4e2a\u6570\u636e\u96c6\u8fdb\u884c\u9884\u6d4b\u3002\u7136\u540e\uff0c\u5bf9\u8fd9\u4e9b\u9884\u6d4b\u8fdb\u884c\u975e\u89c4\u8303\u5316\u4ee5\u83b7\u5f97\u5b9e\u9645\u7684\u80a1\u7968\u4ef7\u683c\u3002\u6211\u4eec\u8ba1\u7b97\u6bcf\u53ea\u80a1\u7968\u7684\u5e73\u5747\u7edd\u5bf9\u8bef\u5dee \uff08MAE\uff09 \u4ee5\u8bc4\u4f30\u6a21\u578b\u7684\u8868\u73b0\u3002<\/p>\n\n\n\n<p><strong>\u53ef\u89c6\u5316\uff1a<\/strong><br>\u6700\u540e\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u56fe\u8868\uff0c\u6bd4\u8f83\u4e00\u6bb5\u65f6\u95f4\u5185\u7684\u5b9e\u9645\u548c\u9884\u6d4b\u80a1\u7968\u4ef7\u683c\uff0c\u4ee5\u4fbf\u76f4\u89c2\u5730\u68c0\u67e5\u6a21\u578b\u7684\u6027\u80fd\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/b15eb5653b85d65f0df571b286e2f8fa.webp\" alt=\"\" class=\"wp-image-1790\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.3 \u6570\u636e\u51c6\u5907<\/strong><\/h3>\n\n\n\n<p>\u8ba9\u6211\u4eec\u5206\u89e3\u4e00\u4e0b\u6211\u4eec\u5b9e\u73b0\u7684\u5173\u952e\u7ec4\u4ef6\uff1a\u6570\u636e\u51c6\u5907\u3002<br>\u6211\u4eec\u9996\u5148\u4f7f\u7528 yfinance \u5e93\u4e0b\u8f7d\u5386\u53f2\u80a1\u7968\u4ef7\u683c\u6570\u636e\u3002\u8fd9\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e2a DataFrame\uff0c\u5176\u4e2d\u5305\u542b\u6211\u4eec\u6240\u9009\u80a1\u7968\u5728\u4e00\u5e74\u5185\u7684\u6536\u76d8\u4ef7\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>data = yf.download\uff08tickers\uff0c period='1y'\uff0c interval='1d'\uff09&#91;'Close']<\/code><code>data = data.dropna\uff08\uff09 # \u5220\u9664\u7f3a\u5931\u503c<\/code><\/code><\/pre>\n\n\n\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528 MinMaxScaler \u5bf9\u6570\u636e\u8fdb\u884c\u5f52\u4e00\u5316\u3002\u6b64\u6b65\u9aa4\u81f3\u5173\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u786e\u4fdd\u6240\u6709\u7279\u5f81\u90fd\u5904\u4e8e\u76f8\u540c\u7684\u6bd4\u4f8b\u4e0a\uff0c\u8fd9\u6709\u52a9\u4e8e\u6a21\u578b\u6536\u655b\u548c\u6027\u80fd\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><code>scaler = MinMaxScaler\uff08\uff09<\/code><code>normalized_prices = scaler.fit_transform\uff08data.values\uff09<\/code><\/code><\/pre>\n\n\n\n<p><strong>\u56fe\u5f62\u6784\u5efa\uff1a<\/strong><br>\u6211\u4eec\u4ece\u6807\u51c6\u5316\u7684\u4ef7\u683c\u6570\u636e\u4e2d\u8ba1\u7b97\u51fa\u4e00\u4e2a\u76f8\u5173\u77e9\u9635\u3002\u8be5\u77e9\u9635\u6839\u636e\u4ef7\u683c\u53d8\u52a8\u8868\u793a\u4e0d\u540c\u80a1\u7968\u4e4b\u95f4\u7684\u5173\u7cfb\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>correlation_matrix = np.corrcoef\uff08normalized_prices.T)<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528\u6b64\u76f8\u5173\u77e9\u9635\u5728\u76f8\u5173\u6027\u9ad8\u4e8e\u7279\u5b9a\u9608\u503c\u7684\u80a1\u7968\u4e4b\u95f4\u521b\u5efa\u8fb9\u3002\u8fd9\u6784\u6210\u4e86\u6211\u4eec\u7684\u56fe\u5f62\u7ed3\u6784\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><code>edge_index = np.array\uff08np.where\uff08correlation_matrix &gt; 0.5\uff09\uff09edge_index<\/code><code>= torch.tensor\uff08edge_index\uff0c dtype=torch.long\uff09<\/code><\/code><\/pre>\n\n\n\n<p><strong>\u6a21\u578b\u5b9a\u4e49\uff1a<\/strong><br>\u6211\u4eec\u7684 ImprovedGraphNeuralOperator \u7c7b\u5b9a\u4e49\u4e86\u6211\u4eec\u7684 GNO \u7684\u67b6\u6784\u3002\u5b83\u7531\u591a\u4e2a\u56fe\u5f62\u5377\u79ef\u5c42 \uff08GCNConv\uff09 \u548c\u5168\u8fde\u63a5\u5c42\u7ec4\u6210\u3002\u6211\u4eec\u8fd8\u52a0\u5165\u4e86 dropout \u4ee5\u8fdb\u884c\u6b63\u5219\u5316\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><code>class ImprovedGraphNeuralOperator(nn.Module):<\/code><code>  def __init__(self, input_dim, hidden_dim, output_dim):<\/code><code>    super(ImprovedGraphNeuralOperator, self).__init__()<\/code><code>    self.conv1 = GCNConv(input_dim, hidden_dim)<\/code><code>    self.conv2 = GCNConv(hidden_dim, hidden_dim)<\/code><code>    self.conv3 = GCNConv(hidden_dim, hidden_dim)<\/code><code>    self.fc1 = nn.Linear(hidden_dim, hidden_dim)<\/code><code>    self.fc2 = nn.Linear(hidden_dim, output_dim)<\/code><code>    self.dropout = nn.Dropout(0.2)<\/code><code><br><\/code><code>  def forward(self, data):<\/code><code>    x, edge_index = data.x, data.edge_index<\/code><code>    x = F.relu(self.conv1(x, edge_index))<\/code><code>    x = self.dropout(x)<\/code><code>    x = F.relu(self.conv2(x, edge_index))<\/code><code>    x = self.dropout(x)<\/code><code>    x = F.relu(self.conv3(x, edge_index))<\/code><code>    x = self.dropout(x)<\/code><code>    x = F.relu(self.fc1(x))<\/code><code>    x = self.fc2(x)<\/code><code>    return x<\/code><\/code><\/pre>\n\n\n\n<p>\u8fd9\u79cd\u67b6\u6784\u5141\u8bb8\u901a\u8fc7\u56fe\u5377\u79ef\u5c42\u5728\u8282\u70b9\uff08\u80a1\u7968\uff09\u4e4b\u95f4\u4f20\u9012\u6d88\u606f\uff0c\u7136\u540e\u5728\u5b8c\u5168\u8fde\u63a5\u7684\u5c42\u4e2d\u8fdb\u884c\u8fdb\u4e00\u6b65\u5904\u7406\u3002<\/p>\n\n\n\n<p><br><strong>\u8bad\u7ec3\u5faa\u73af\uff1a<\/strong><br>\u6211\u4eec\u4f7f\u7528\u5747\u65b9\u8bef\u5dee\u4f5c\u4e3a\u635f\u5931\u51fd\u6570\uff0c\u4f7f\u7528 Adam \u4f5c\u4e3a\u4f18\u5316\u5668\u6765\u8bad\u7ec3\u6a21\u578b\u3002\u8bad\u7ec3\u5faa\u73af\u904d\u5386\u591a\u4e2a epoch\uff0c\u6267\u884c\u5411\u524d\u548c\u5411\u540e\u4f20\u9012\u4ee5\u66f4\u65b0\u6a21\u578b\u53c2\u6570\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><code>for epoch in range(epochs):<\/code><code>  model.train()<\/code><code>  optimizer.zero_grad()<\/code><code><br><\/code><code>  out = model(graph_data)<\/code><code>  loss = criterion(out, graph_data.x)<\/code><code><br><\/code><code>  loss.backward()<\/code><code>  optimizer.step()<\/code><code><br><\/code><code>  if (epoch + 1) % 50 == 0:<\/code><code>  print(f\u2019Epoch &#91;{epoch+1}\/{epochs}], Loss: {loss.item():.4f}\u2019)<\/code><\/code><\/pre>\n\n\n\n<p><strong>\u9884\u6d4b\u548c\u8bc4\u4f30\uff1a<\/strong><br>\u8bad\u7ec3\u540e\uff0c\u6211\u4eec\u4f7f\u7528\u6a21\u578b\u5bf9\u6574\u4e2a\u6570\u636e\u96c6\u8fdb\u884c\u9884\u6d4b\u3002\u7136\u540e\uff0c\u5bf9\u8fd9\u4e9b\u9884\u6d4b\u8fdb\u884c\u975e\u89c4\u8303\u5316\u4ee5\u83b7\u5f97\u5b9e\u9645\u7684\u80a1\u7968\u4ef7\u683c\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><code>model.eval()<\/code><code>with torch.no_grad():<\/code><code>predicted_prices = model(graph_data).detach().numpy()<\/code><code><br><\/code><code>predicted_prices = predicted_prices.T<\/code><code>predicted_prices = scaler.inverse_transform(predicted_prices)<\/code><\/code><\/pre>\n\n\n\n<p>\u6211\u4eec\u8ba1\u7b97\u6bcf\u53ea\u80a1\u7968\u7684\u5e73\u5747\u7edd\u5bf9\u8bef\u5dee \uff08MAE\uff09 \u4ee5\u8bc4\u4f30\u6a21\u578b\u7684\u8868\u73b0\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><code>for i, ticker in enumerate(tickers):<\/code><code>  mae = np.mean(np.abs(data.values&#91;:, i] \u2014 predicted_prices&#91;:, i]))<\/code><code>  print(f\u201dMean Absolute Error for {ticker}: {mae:.2f}\u201d)<\/code><\/code><\/pre>\n\n\n\n<p><strong>\u53ef\u89c6\u5316\uff1a<\/strong><br>\u6700\u540e\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u56fe\u8868\uff0c\u6bd4\u8f83\u4e00\u6bb5\u65f6\u95f4\u5185\u7684\u5b9e\u9645\u548c\u9884\u6d4b\u80a1\u7968\u4ef7\u683c\u3002\u8fd9\u5141\u8bb8\u5bf9\u6a21\u578b\u7684\u6027\u80fd\u8fdb\u884c\u76ee\u89c6\u68c0\u67e5\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><code>plt.figure(figsize=(15, 10))<\/code><code>for i, ticker in enumerate(tickers):<\/code><code>plt.plot(data.index, predicted_prices&#91;:, i], label=f\u2019Predicted \u2014 {ticker}\u2019, linestyle=\u2019 \u2014 \u2018)<\/code><code>plt.plot(data.index, data.values&#91;:, i], label=f\u2019Actual \u2014 {ticker}\u2019)<\/code><code><br><\/code><code>plt.xlabel(\u2018Date\u2019)<\/code><code>plt.ylabel(\u2018Stock Price\u2019)<\/code><code>plt.title(\u2018Actual vs. Predicted Stock Prices Over Time Using Improved GNO\u2019)<\/code><code>plt.legend(bbox_to_anchor=(1.05, 1), loc=\u2019upper left\u2019)<\/code><code>plt.tight_layout()<\/code><code>plt.grid(True, alpha=0.3)<\/code><code>plt.show()<\/code><\/code><\/pre>\n\n\n\n<p>\u8fd9\u79cd\u53ef\u89c6\u5316\u6709\u52a9\u4e8e\u4e86\u89e3\u6a21\u578b\u6355\u83b7\u80a1\u7968\u4ef7\u683c\u968f\u65f6\u95f4\u53d8\u5316\u7684\u8d8b\u52bf\u548c\u6a21\u5f0f\u7684\u80fd\u529b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e09\u3001\u7ed3\u8bba<\/strong><\/h2>\n\n\n\n<p>Graph Neural Operators \u63d0\u4f9b\u4e86\u4e00\u79cd\u5f3a\u5927\u7684\u65b9\u6cd5\u6765\u5bf9\u80a1\u7968\u5e02\u573a\u7b49\u590d\u6742\u7cfb\u7edf\u8fdb\u884c\u5efa\u6a21\u3002\u901a\u8fc7\u6355\u83b7\u80a1\u7968\u4e4b\u95f4\u7684\u76f8\u4e92\u4f9d\u8d56\u5173\u7cfb\uff0c\u6211\u4eec\u7684 GNO \u6a21\u578b\u6709\u53ef\u80fd\u505a\u51fa\u6bd4\u4f20\u7edf\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\u66f4\u660e\u667a\u7684\u9884\u6d4b\u3002<\/p>\n\n\n\n<p>\u7136\u800c\uff0c\u91cd\u8981\u7684\u662f\u8981\u6ce8\u610f\uff0c\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u662f\u4e00\u9879\u6781\u5177\u6311\u6218\u6027\u7684\u4efb\u52a1\uff0c\u53d7\u8bb8\u591a\u56e0\u7d20\u7684\u5f71\u54cd\uff0c\u5176\u4e2d\u8bb8\u591a\u56e0\u7d20\u662f\u4e0d\u53ef\u9884\u6d4b\u7684\u3002\u867d\u7136\u6211\u4eec\u7684 GNO \u6a21\u578b\u63d0\u4f9b\u4e86\u4e00\u79cd\u6709\u8da3\u7684\u65b9\u6cd5\uff0c\u4f46\u5b83\u5e94\u8be5\u4e0e\u5176\u4ed6\u5206\u6790\u65b9\u6cd5\u7ed3\u5408\u4f7f\u7528\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u7528\u4e8e\u505a\u51fa\u6295\u8d44\u51b3\u7b56\u3002\u4e0e\u4efb\u4f55\u673a\u5668\u5b66\u4e60\u6a21\u578b\u4e00\u6837\uff0c\u6301\u7eed\u4f18\u5316\u3001\u7279\u5f81\u5de5\u7a0b\u548c\u4e25\u683c\u7684\u56de\u6eaf\u6d4b\u8bd5\u5bf9\u4e8e\u63d0\u9ad8\u5b9e\u9645\u5e94\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u53ef\u9760\u6027\u81f3\u5173\u91cd\u8981\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u672c\u6587\u5185\u5bb9\u4ec5\u4ec5\u662f\u6280\u672f\u63a2\u8ba8\u548c\u5b66\u4e60\uff0c\u5e76\u4e0d\u6784\u6210\u4efb\u4f55\u6295\u8d44\u5efa\u8bae\u3002<\/mark><\/strong><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u8f6c\u53d1\u8bf7\u6ce8\u660e\u539f\u4f5c\u8005\u548c\u51fa\u5904\u3002<\/mark><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u8001\u4f59\u635e\u9c7c \u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/laoyulaoyu.com\/index.php\/2024\/09\/15\/%e5%9b%be%e7%a5%9e%e7%bb%8f%e8%bf%90%e7%ae%97%e7%ac%a6-%ef%bc%88gno%ef%bc%89%e8%83%bd%e4%b8%8d%e8%83%bd%e7%94%a8%e4%ba%8e%e7%82%92%e8%82%a1%ef%bc%9f\/\">Continue reading<span class=\"screen-reader-text\">\u56fe\u795e\u7ecf\u8fd0\u7b97\u7b26 \uff08GNO\uff09\u80fd\u4e0d\u80fd\u7528\u4e8e\u7092\u80a1\uff1f<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5],"class_list":["post-1424","post","type-post","status-publish","format-standard","hentry","category-aiinvest","tag-ai","entry"],"_links":{"self":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/comments?post=1424"}],"version-history":[{"count":1,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1424\/revisions"}],"predecessor-version":[{"id":1425,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1424\/revisions\/1425"}],"wp:attachment":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=1424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=1424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=1424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}