{"id":3904,"date":"2026-07-28T07:39:49","date_gmt":"2026-07-27T23:39:49","guid":{"rendered":"https:\/\/www.khsci.com\/docs\/?p=3904"},"modified":"2026-07-28T07:39:49","modified_gmt":"2026-07-27T23:39:49","slug":"cnn-rnn-classification-python","status":"publish","type":"post","link":"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/","title":{"rendered":"CNN-RNN\u901a\u7528\u5206\u7c7bPython\u4ee3\u7801"},"content":{"rendered":"\n<p>\u672c\u6587\u4ecb\u7ecd\u4e00\u5957\u57fa\u4e8e PyTorch \u7684 CNN-RNN \u901a\u7528\u5206\u7c7b\u4ee3\u7801\u3002\u6838\u5fc3\u51fd\u6570\u4f1a\u5728\u6bcf\u6761\u6837\u672c\u5185\u90e8\u9009\u62e9\u4e00\u4e2a\u201c\u5e8f\u5217\u8f74\u201d\uff1a\u4e00\u7ef4\u7279\u5f81\u53ef\u4ee5\u6cbf\u7279\u5f81\u4f4d\u7f6e\u8bfb\u53d6\uff0c\u591a\u901a\u9053\u4f20\u611f\u5668\u6570\u636e\u53ef\u4ee5\u6cbf\u65f6\u95f4\u8bfb\u53d6\uff0c\u4e8c\u7ef4\u56fe\u50cf\u53ef\u4ee5\u9010\u5217\u8bfb\u53d6\uff1b\u5176\u4f59\u7ef4\u5ea6\u4f1a\u81ea\u52a8\u5408\u5e76\u4e3a\u6bcf\u4e00\u6b65\u7684\u8f93\u5165\u7279\u5f81\u3002\u8fd9\u6837\u65e0\u9700\u4e3a\u6bcf\u4e00\u79cd\u8f93\u5165\u5f62\u72b6\u91cd\u65b0\u7f16\u5199\u8bad\u7ec3\u3001\u8bc4\u4ef7\u548c\u7ed8\u56fe\u6d41\u7a0b\u3002<\/p>\n\n\n\n<ul>\n<li>\u63d0\u4f9b Iris \u4e00\u7ef4\u7279\u5f81\u3001UCI HAR \u4e5d\u901a\u9053\u4eba\u4f53\u6d3b\u52a8\u5e8f\u5217\u3001MNIST \u4e8c\u7ef4\u7070\u5ea6\u56fe\u4e09\u4e2a\u53ef\u76f4\u63a5\u8fd0\u884c\u7684demo\u3002<\/li>\n<li>\u652f\u6301\u6837\u672c\u653e\u7b2c\u4e00\u7ef4\u6216\u6700\u540e\u4e00\u7ef4\uff0c\u5e76\u901a\u8fc7 <code>sequenceAxis<\/code> \u6307\u5b9a\u771f\u6b63\u6709\u987a\u5e8f\u7684\u8f74\u3002<\/li>\n<li>\u53ef\u4ee5\u8bbe\u7f6e\u591a\u5c42\u4e00\u7ef4CNN\u3001\u5377\u79ef\u901a\u9053\u3001\u5377\u79ef\u6838\u3001\u6c60\u5316\u3001\u5faa\u73af\u5c42\u3001\u9690\u85cf\u5355\u5143\u3001\u5faa\u73af\u5c42\u6570\u548c Dropout\u3002<\/li>\n<li>Python \u7248\u652f\u6301 RNN\u3001LSTM\u3001GRU\u3001BiRNN\u3001BiLSTM\u3001BiGRU \u516d\u79cd\u5faa\u73af\u7ed3\u6784\u3002<\/li>\n<li>\u652f\u6301\u5206\u5c42\u968f\u673a\u5212\u5206\uff0c\u4e5f\u652f\u6301\u6309\u4eba\u5458\u3001\u8bbe\u5907\u3001\u5de5\u51b5\u6216\u6279\u6b21\u63d0\u4f9b\u56fa\u5b9a\u7684 <code>splitLabels<\/code>\u3002<\/li>\n<li>\u5f52\u4e00\u5316\u5747\u503c\u4e0e\u6807\u51c6\u5dee\u53ea\u4ece\u8bad\u7ec3\u96c6\u8ba1\u7b97\uff0c\u9a8c\u8bc1\u96c6\u548c\u6d4b\u8bd5\u96c6\u4e0d\u53c2\u4e0e\u62df\u5408\u3002<\/li>\n<li>\u81ea\u52a8\u8ba1\u7b97 Accuracy\u3001\u5b8f\u5e73\u5747 Precision\u3001Recall\u3001F1\u3001\u9010\u7c7b\u522b\u6307\u6807\u4e0e\u6df7\u6dc6\u77e9\u9635\u3002<\/li>\n<li>\u81ea\u52a8\u751f\u6210\u5e76\u4fdd\u5b58\u6536\u655b\u8fc7\u7a0b\u3001\u6df7\u6dc6\u77e9\u9635\u3001\u5404\u7c7b\u522b\u6307\u6807\u3001\u5206\u7c7b\u7ed3\u679c\u5bf9\u6bd4\u3001\u4e09\u96c6\u5408\u6307\u6807\u5bf9\u6bd4\u4e94\u7c7b\u56fe\u7247\uff1b\u4e09\u4e2a\u6848\u4f8b\u517115\u5f20\u56fe\u3002<\/li>\n<li>\u53ef\u8bbe\u7f6e Adam\u3001SGDM\u3001RMSprop\uff0c\u652f\u6301\u5b66\u4e60\u7387\u8870\u51cf\u3001\u65e9\u505c\u3001\u7c7b\u522b\u6743\u91cd\u548c CPU\/GPU \u81ea\u52a8\u9009\u62e9\u3002<\/li>\n<li>\u7528\u6237\u4e3b\u8981\u8d1f\u8d23\u5bfc\u5165 <code>X<\/code>\u3001<code>Y<\/code>\uff0c\u9009\u5bf9\u5e8f\u5217\u8f74\u5e76\u8c03\u53c2\uff0c\u56fa\u5b9a\u6d41\u7a0b\u7531 <code>FunClassCNNRNN<\/code> \u4e00\u884c\u5b8c\u6210\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e00\u3001\u4ee3\u7801\u8fd0\u884c\u73af\u5883<\/h4>\n\n\n\n<p>\u63a8\u8350\u4f7f\u7528 Windows 64\u4f4d\u3001Python 3.11\u3001PyTorch\u3002\u5f00\u53d1\u548c\u6d4b\u8bd5\u73af\u5883\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-text\">Python 3.11.9\ntorch 2.8.0+cpu\nnumpy 2.2.6\nscikit-learn 1.6.1\nmatplotlib 3.10.3<\/code><\/pre>\n\n\n\n<p>\u5728\u4ee3\u7801\u6587\u4ef6\u5939\u4e2d\u6267\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-bash\">pip install -r requirements.txt<\/code><\/pre>\n\n\n\n<p>\u5b8c\u6574\u7248\u4e3a Python \u6e90\u7801\uff0c\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u73af\u5883\u8c03\u6574\u4f9d\u8d56\u3002\u516c\u5f00\u7248\u7a0b\u5e8f\u6309 Windows 64\u4f4d Python 3.11 \u7f16\u8bd1\uff0c\u5fc5\u987b\u4f7f\u7528 Python 3.11 x64\uff1b\u5176\u4ed6Python\u5927\u7248\u672c\u53ef\u80fd\u65e0\u6cd5\u52a0\u8f7d\u516c\u5f00\u7248\u6838\u5fc3\u6a21\u5757\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u9700\u8981GPU\u8bad\u7ec3\uff0c\u8bf7\u6839\u636e\u663e\u5361\u9a71\u52a8\u4e0eCUDA\u7248\u672c\u5b89\u88c5\u5bf9\u5e94\u7684 PyTorch\u3002\u4ee3\u7801\u8bbe\u7f6e <code>deviceSel=&#039;auto&#039;<\/code> \u65f6\u4f1a\u4f18\u5148\u4f7f\u7528\u53ef\u7528GPU\uff0c\u5426\u5219\u81ea\u52a8\u4f7f\u7528CPU\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e8c\u3001\u7a0b\u5e8f\u4ecb\u7ecd<\/h4>\n\n\n\n<p>\u5b8c\u6574\u7248\u6587\u4ef6\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-text\">CNN_RNN_Classification\/\n\u251c\u2500\u2500 demoCNNRNNClassIris.py\n\u251c\u2500\u2500 demoCNNRNNClassHAR.py\n\u251c\u2500\u2500 demoCNNRNNClassMNIST.py\n\u251c\u2500\u2500 FunClassCNNRNN.py\n\u251c\u2500\u2500 EvaClassEffect.py\n\u251c\u2500\u2500 iris.csv\n\u251c\u2500\u2500 har_activity_data.npz\n\u251c\u2500\u2500 mnist_subset.npz\n\u251c\u2500\u2500 requirements.txt\n\u251c\u2500\u2500 \u6570\u636e\u6765\u6e90\u4e0e\u8bb8\u53ef.txt\n\u251c\u2500\u2500 \u4ee3\u7801\u8bf4\u660e.txt\n\u2514\u2500\u2500 figure\/<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">1. demoCNNRNNClassIris.py \u6587\u4ef6<\/h6>\n\n\n\n<p>\u8be5\u811a\u672c\u6f14\u793a\u4e8c\u7ef4\u8f93\u5165\u7684\u4e00\u7ef4\u7279\u5f81\u5206\u7c7b\u3002<code>X.shape=(150,4)<\/code>\uff0c\u8868\u793a150\u6761\u6837\u672c\u3001\u6bcf\u67614\u4e2a\u7279\u5f81\u4f4d\u7f6e\uff1b<code>Y.shape=(150,)<\/code>\uff0c\u4fdd\u5b58\u4e09\u79cd\u9e22\u5c3e\u82b1\u7c7b\u522b\u3002\u811a\u672c\u8bbe\u7f6e <code>sequenceAxis=0<\/code>\uff0c\u628a\u5355\u6761\u6837\u672c\u5185\u90e8\u7684\u56db\u4e2a\u7279\u5f81\u4f9d\u6b21\u4ea4\u7ed9 CNN-LSTM\u3002<\/p>\n\n\n\n<p>\u6838\u5fc3\u8c03\u7528\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\">foreData, foreDataTrain, model, info = FunClassCNNRNN(X, Y, options)<\/code><\/pre>\n\n\n\n<p>\u672c\u6b21\u5b8c\u6574\u590d\u9a8c\u7684\u6d4b\u8bd5\u96c6 Accuracy \u4e3a <code>1.0000<\/code>\uff0cMacro-F1 \u4e3a <code>1.0000<\/code>\u3002\u6d4b\u8bd5\u96c6\u53ea\u670930\u6761\u6837\u672c\uff0c\u56e0\u6b64\u8be5\u6570\u5b57\u4e3b\u8981\u7528\u4e8e\u786e\u8ba4\u6d41\u7a0b\u6b63\u5e38\uff0c\u4e0d\u4ee3\u8868\u5176\u4ed6\u6570\u636e\u4e5f\u80fd\u8fbe\u5230\u76f8\u540c\u7ed3\u679c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.khsci.com\/docs\/wp-content\/uploads\/2026\/07\/cnn-rnn-classification-python-iris-confusion.png\" alt=\"Python Iris \u6d4b\u8bd5\u96c6\u6df7\u6dc6\u77e9\u9635\"\/><\/figure>\n\n\n\n<p>\u56fe 1 \u5c55\u793a\u4e09\u4e2a\u7c7b\u522b\u7684\u771f\u5b9e\u6807\u7b7e\u4e0e\u9884\u6d4b\u6807\u7b7e\u3002\u4e3b\u5bf9\u89d2\u7ebf\u8868\u793a\u9884\u6d4b\u6b63\u786e\uff0c\u975e\u5bf9\u89d2\u7ebf\u8868\u793a\u5177\u4f53\u8bef\u5206\u65b9\u5411\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">2. demoCNNRNNClassHAR.py \u6587\u4ef6<\/h6>\n\n\n\n<p>\u8be5\u811a\u672c\u6f14\u793a\u591a\u901a\u9053\u5e8f\u5217\u5206\u7c7b\u3002<code>X.shape=(2700,9,128)<\/code>\uff1a\u6bcf\u6761\u6837\u672c\u5305\u542b9\u4e2a\u4f20\u611f\u5668\u901a\u9053\u3001128\u4e2a\u8fde\u7eed\u91c7\u6837\u70b9\uff1b<code>Y<\/code> \u662f\u884c\u8d70\u3001\u4e0a\u697c\u3001\u4e0b\u697c\u3001\u5750\u7740\u3001\u7ad9\u7acb\u3001\u8eba\u7740\u516d\u7c7b\u6807\u7b7e\u3002<\/p>\n\n\n\n<p>\u811a\u672c\u8bbe\u7f6e <code>sequenceAxis=1<\/code>\u3002\u8fd9\u91cc\u7684\u7f16\u53f7\u662f\u201c\u5355\u6761\u6837\u672c\u5185\u90e8\u4ece0\u5f00\u59cb\u201d\uff0c\u6240\u4ee5 <code>[9,128]<\/code> \u4e2d\u7b2c1\u8f74\u5c31\u662f\u957f\u5ea6128\u7684\u65f6\u95f4\u8f74\u30029\u4e2a\u901a\u9053\u4f1a\u6210\u4e3a\u6bcf\u4e2a\u65f6\u95f4\u70b9\u4e0a\u76849\u4e2a\u8f93\u5165\u7279\u5f81\u3002<\/p>\n\n\n\n<p>HAR \u4f7f\u7528 <code>splitLabels<\/code> \u6309\u53d7\u8bd5\u8005\u9694\u79bb\uff1a1500\u6761\u8bad\u7ec3\u3001480\u6761\u9a8c\u8bc1\u3001720\u6761\u6d4b\u8bd5\u3002\u6d4b\u8bd5\u4eba\u5458\u6ca1\u6709\u53c2\u4e0e\u8bad\u7ec3\u548c\u9a8c\u8bc1\uff0c\u6bd4\u968f\u673a\u62c6\u5206\u66f4\u63a5\u8fd1\u9762\u5bf9\u65b0\u7528\u6237\u65f6\u7684\u771f\u5b9e\u6548\u679c\u3002<\/p>\n\n\n\n<p>\u672c\u6b21\u5b8c\u6574\u590d\u9a8c\u7684\u6d4b\u8bd5\u96c6 Accuracy \u4e3a <code>0.8931<\/code>\uff0cMacro-F1 \u4e3a <code>0.8925<\/code>\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.khsci.com\/docs\/wp-content\/uploads\/2026\/07\/cnn-rnn-classification-python-har-loss.png\" alt=\"Python HAR \u6536\u655b\u8fc7\u7a0b\"\/><\/figure>\n\n\n\n<p>\u56fe 2 \u540c\u65f6\u5c55\u793a\u8bad\u7ec3\/\u9a8c\u8bc1\u635f\u5931\u548c\u51c6\u786e\u7387\u3002\u6700\u4f73\u6743\u91cd\u6309\u7167\u9a8c\u8bc1\u635f\u5931\u9009\u62e9\uff0c\u9a8c\u8bc1\u635f\u5931\u957f\u671f\u4e0d\u6539\u5584\u65f6\u63d0\u524d\u505c\u6b62\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.khsci.com\/docs\/wp-content\/uploads\/2026\/07\/cnn-rnn-classification-python-har-confusion.png\" alt=\"Python HAR \u6d4b\u8bd5\u96c6\u6df7\u6dc6\u77e9\u9635\"\/><\/figure>\n\n\n\n<p>\u56fe 3 \u7528\u4e8e\u5b9a\u4f4d\u516d\u79cd\u6d3b\u52a8\u4e4b\u95f4\u7684\u5177\u4f53\u6df7\u6dc6\u3002\u5750\u7740\u4e0e\u7ad9\u7acb\u7684\u4f20\u611f\u5668\u53d8\u5316\u76f8\u8fd1\uff0c\u901a\u5e38\u6bd4\u52a8\u6001\u6d3b\u52a8\u66f4\u96be\u533a\u5206\uff0c\u8fd9\u4e5f\u662f\u6df7\u6dc6\u77e9\u9635\u6bd4\u5355\u4e00\u51c6\u786e\u7387\u66f4\u6709\u4ef7\u503c\u7684\u5730\u65b9\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.khsci.com\/docs\/wp-content\/uploads\/2026\/07\/cnn-rnn-classification-python-har-class-metrics.png\" alt=\"Python HAR \u5404\u7c7b\u522b\u6307\u6807\"\/><\/figure>\n\n\n\n<p>\u56fe 4 \u5206\u522b\u7ed9\u51fa\u5404\u7c7b Precision\u3001Recall\u3001F1\uff0c\u80fd\u53d1\u73b0\u67d0\u4e2a\u5c11\u6570\u7c7b\u6216\u96be\u5206\u7c7b\u7c7b\u522b\u662f\u5426\u88ab\u603b\u51c6\u786e\u7387\u63a9\u76d6\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">3. demoCNNRNNClassMNIST.py \u6587\u4ef6<\/h6>\n\n\n\n<p>\u8be5\u811a\u672c\u6f14\u793a\u4e8c\u7ef4\u7070\u5ea6\u56fe\u5206\u7c7b\u3002<code>X.shape=(5000,28,28)<\/code>\uff0c\u8868\u793a5000\u5f2028\u00d728\u7070\u5ea6\u56fe\uff1b<code>Y<\/code> \u4e3a0~9\u5341\u7c7b\u6570\u5b57\u3002\u8bbe\u7f6e <code>sequenceAxis=1<\/code> \u540e\uff0c\u7a0b\u5e8f\u6cbf\u5bbd\u5ea6\u65b9\u5411\u9010\u5217\u8bfb\u53d6\u56fe\u50cf\uff1a\u6bcf\u4e00\u6b65\u63a5\u6536\u4e00\u521728\u4e2a\u50cf\u7d20\uff0cCNN\u63d0\u53d6\u76f8\u90bb\u5217\u4e2d\u7684\u7b14\u753b\u7ec4\u5408\uff0cGRU\u518d\u6c47\u603b\u6574\u5f20\u56fe\u7684\u4fe1\u606f\u3002<\/p>\n\n\n\n<p>\u672c\u6b21\u5b8c\u6574\u590d\u9a8c\u7684\u6d4b\u8bd5\u96c6 Accuracy \u4e3a <code>0.9260<\/code>\uff0cMacro-F1 \u4e3a <code>0.9260<\/code>\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.khsci.com\/docs\/wp-content\/uploads\/2026\/07\/cnn-rnn-classification-python-mnist-confusion.png\" alt=\"Python MNIST \u6d4b\u8bd5\u96c6\u6df7\u6dc6\u77e9\u9635\"\/><\/figure>\n\n\n\n<p>\u56fe 5 \u5c55\u793a\u5404\u6570\u5b57\u7684\u6b63\u786e\u6570\u91cf\u548c\u8bef\u5206\u65b9\u5411\u3002\u82e5\u9700\u8981\u7ee7\u7eed\u63d0\u9ad8\u56fe\u50cf\u5206\u7c7b\u7cbe\u5ea6\uff0c\u53ef\u4ee5\u589e\u52a0\u8bad\u7ec3\u6570\u636e\u548c\u7f51\u7edc\u5bb9\u91cf\uff0c\u4e5f\u5e94\u4e0e\u6807\u51c6\u4e8c\u7ef4CNN\u8fdb\u884c\u5bf9\u6bd4\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">4. FunClassCNNRNN.py \u6587\u4ef6<\/h6>\n\n\n\n<p>\u8be5\u6587\u4ef6\u5305\u542b\u6838\u5fc3\u51fd\u6570\u548c PyTorch \u7f51\u7edc\u7c7b\u3002\u6838\u5fc3\u51fd\u6570\u7b7e\u540d\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\">def FunClassCNNRNN(X, Y, options=None):\n    ...\n    return foreData, foreDataTrain, model, info<\/code><\/pre>\n\n\n\n<p>\u8f93\u5165\u53c2\u6570\uff1a<\/p>\n\n\n\n<ul>\n<li><code>X<\/code>\uff1a\u4efb\u610f\u7ef4\u5ea6\u6709\u9650\u6570\u503c NumPy \u6570\u7ec4\uff0c\u4e0d\u80fd\u542b NaN \u6216 Inf\u3002\u63a8\u8350\u6837\u672c\u653e\u7b2c\u4e00\u7ef4\uff0c\u4e5f\u517c\u5bb9\u653e\u6700\u540e\u4e00\u7ef4\u3002<\/li>\n<li><code>Y<\/code>\uff1a\u6bcf\u6761\u6837\u672c\u7684\u7c7b\u522b\u6807\u7b7e\uff0c\u957f\u5ea6\u7b49\u4e8e\u6837\u672c\u6570\uff1b\u652f\u6301\u6574\u6570\u3001\u6d6e\u70b9\u6570\u6216\u5b57\u7b26\u4e32\u7c7b\u522b\u3002<\/li>\n<li><code>options<\/code>\uff1a\u63a7\u5236\u8f93\u5165\u9002\u914d\u3001\u6570\u636e\u5212\u5206\u3001\u7f51\u7edc\u3001\u8bad\u7ec3\u3001\u5f52\u4e00\u5316\u4e0e\u7ed8\u56fe\u7684\u5b57\u5178\u3002\u5b57\u6bb5\u53ef\u90e8\u5206\u7701\u7565\uff0c\u7f3a\u5c11\u5b57\u6bb5\u91c7\u7528\u9ed8\u8ba4\u503c\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u8f93\u51fa\u53c2\u6570\uff1a<\/p>\n\n\n\n<ul>\n<li><code>foreData<\/code>\uff1a\u6d4b\u8bd5\u96c6\u9884\u6d4b\u6807\u7b7e\uff0c\u5df2\u7ecf\u8fd8\u539f\u4e3a <code>Y<\/code> \u7684\u539f\u59cb\u7c7b\u522b\u503c\u3002<\/li>\n<li><code>foreDataTrain<\/code>\uff1a\u8bad\u7ec3\u96c6\u9884\u6d4b\u6807\u7b7e\u3002<\/li>\n<li><code>model<\/code>\uff1a\u6062\u590d\u5230\u6700\u4f73\u9a8c\u8bc1\u635f\u5931\u72b6\u6001\u7684 PyTorch \u6a21\u578b\u3002<\/li>\n<li><code>info<\/code>\uff1a\u5305\u542b\u4e09\u96c6\u5408\u7d22\u5f15\u4e0e\u771f\u5b9e\u6807\u7b7e\u3001\u9a8c\u8bc1\u96c6\u9884\u6d4b\u3001\u4e09\u96c6\u5408\u7c7b\u522b\u6982\u7387\u3001Accuracy\/Precision\/Recall\/F1\u3001\u6df7\u6dc6\u77e9\u9635\u3001\u8bad\u7ec3\u5386\u53f2\u3001\u6700\u4f73\u8f6e\u6b21\u3001\u6807\u51c6\u5316\u53c2\u6570\u3001\u8f93\u5165\u5c3a\u5bf8\u9002\u914d\u8bb0\u5f55\u3001\u8bbe\u5907\u548c\u5b8c\u6574 <code>options<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<h6 class=\"wp-block-heading\">\u8f93\u5165\u9002\u914d\u53c2\u6570<\/h6>\n\n\n\n<figure class=\"wp-block-table\"><table>\n<thead>\n<tr>\n<th style=\"text-align:left\">\u53c2\u6570<\/th>\n<th style=\"text-align:left\">\u9ed8\u8ba4\u503c<\/th>\n<th style=\"text-align:left\">\u5141\u8bb8\u53d6\u503c<\/th>\n<th style=\"text-align:left\">\u542b\u4e49\u4e0e\u6ce8\u610f\u4e8b\u9879<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:left\"><code>sampleDimension<\/code><\/td>\n<td style=\"text-align:left\"><code>&#039;auto&#039;<\/code><\/td>\n<td style=\"text-align:left\"><code>&#039;auto&#039;<\/code> \u6216\u6574\u6570\u8f74\u7f16\u53f7<\/td>\n<td style=\"text-align:left\"><code>X<\/code> \u4e2d\u7684\u6837\u672c\u8f74\u3002\u81ea\u52a8\u6a21\u5f0f\u5148\u68c0\u67e5\u7b2c\u4e00\u7ef4\uff0c\u518d\u517c\u5bb9\u6700\u540e\u4e00\u7ef4\uff1b\u660e\u786e\u7f16\u53f7\u6309Python\u4ece0\u5f00\u59cb\uff0c\u8d1f\u6570\u53ef\u4ece\u672b\u5c3e\u5012\u6570\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>sequenceAxis<\/code><\/td>\n<td style=\"text-align:left\"><code>-1<\/code><\/td>\n<td style=\"text-align:left\">\u5355\u6761\u6837\u672c\u5185\u90e8\u7684\u6574\u6570\u8f74\u7f16\u53f7<\/td>\n<td style=\"text-align:left\">\u771f\u6b63\u5177\u6709\u987a\u5e8f\u7684\u8f74\uff0c\u63090\u5f00\u59cb\uff1b<code>-1<\/code>\u4e3a\u6700\u540e\u4e00\u8f74\u3002\u4e00\u7ef4\u6570\u7ec4\u8bbe0\uff0c<code>[\u901a\u9053,\u65f6\u95f4]<\/code>\u8bbe1\uff0c<code>[\u901a\u9053,\u9ad8,\u5bbd]<\/code>\u6cbf\u5bbd\u5ea6\u8bfb\u53d6\u65f6\u8bbe2\u3002\u9009\u9519\u8f74\u65f6\u6a21\u578b\u53ef\u80fd\u80fd\u8dd1\uff0c\u4f46\u5b66\u5230\u7684\u76f8\u90bb\u5173\u7cfb\u6ca1\u6709\u4e1a\u52a1\u610f\u4e49\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n\n\n<p>\u9002\u914d\u5668\u5148\u628a\u6837\u672c\u8f74\u79fb\u52a8\u5230\u6700\u524d\u9762\uff0c\u518d\u628a\u5e8f\u5217\u8f74\u79fb\u52a8\u5230\u6700\u540e\uff0c\u5176\u4f59\u7ef4\u5ea6\u5408\u5e76\u4e3a\u6bcf\u4e2a\u4f4d\u7f6e\u7684\u7279\u5f81\uff0c\u5f97\u5230 <code>[\u6837\u672c\u6570, \u7279\u5f81\u6570, \u5e8f\u5217\u957f\u5ea6]<\/code>\u3002\u8be5\u4e09\u7ef4\u6570\u7ec4\u76f4\u63a5\u4ea4\u7ed9 <code>Conv1d<\/code>\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">\u6570\u636e\u5212\u5206\u53c2\u6570<\/h6>\n\n\n\n<figure class=\"wp-block-table\"><table>\n<thead>\n<tr>\n<th style=\"text-align:left\">\u53c2\u6570<\/th>\n<th style=\"text-align:left\">\u9ed8\u8ba4\u503c<\/th>\n<th style=\"text-align:left\">\u5141\u8bb8\u53d6\u503c<\/th>\n<th style=\"text-align:left\">\u542b\u4e49\u4e0e\u8c03\u53c2\u5f71\u54cd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:left\"><code>splitLabels<\/code><\/td>\n<td style=\"text-align:left\"><code>None<\/code><\/td>\n<td style=\"text-align:left\">\u4e0eY\u7b49\u957f\u76841\/2\/3\u6570\u7ec4<\/td>\n<td style=\"text-align:left\">\u56fa\u5b9a\u5212\u5206\uff1a1\u8bad\u7ec3\u30012\u9a8c\u8bc1\u30013\u6d4b\u8bd5\u3002\u9002\u5408\u6309\u4eba\u5458\u3001\u8bbe\u5907\u6216\u6279\u6b21\u9694\u79bb\uff1b\u8bbe\u7f6e\u540e <code>rTrain<\/code> \u7b49\u53c2\u6570\u4e0d\u8d1f\u8d23\u96c6\u5408\u5212\u5206\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>rTrain<\/code><\/td>\n<td style=\"text-align:left\"><code>0.80<\/code><\/td>\n<td style=\"text-align:left\"><code>[0.5,1)<\/code><\/td>\n<td style=\"text-align:left\">\u8bad\u7ec3+\u9a8c\u8bc1\u6570\u636e\u6bd4\u4f8b\uff0c\u5176\u4f59\u4e3a\u6700\u7ec8\u6d4b\u8bd5\u96c6\uff1b\u4e0d\u662f\u7eaf\u8bad\u7ec3\u96c6\u6bd4\u4f8b\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>validationRatio<\/code><\/td>\n<td style=\"text-align:left\"><code>0.15<\/code><\/td>\n<td style=\"text-align:left\"><code>(0,0.5)<\/code><\/td>\n<td style=\"text-align:left\">\u9a8c\u8bc1\u96c6\u5360\u8bad\u7ec3+\u9a8c\u8bc1\u6570\u636e\u7684\u6bd4\u4f8b\uff0c\u7528\u4e8e\u65e9\u505c\u548c\u6a21\u578b\u9009\u62e9\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>shuffle<\/code><\/td>\n<td style=\"text-align:left\"><code>True<\/code><\/td>\n<td style=\"text-align:left\"><code>True\/False<\/code><\/td>\n<td style=\"text-align:left\">\u662f\u5426\u5728\u5206\u5c42\u5212\u5206\u524d\u6253\u4e71\u72ec\u7acb\u6837\u672c\u3002\u4e25\u683c\u65f6\u5e8f\u6216\u5206\u7ec4\u6570\u636e\u5e94\u63d0\u4f9b\u56fa\u5b9a\u5212\u5206\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>seed<\/code><\/td>\n<td style=\"text-align:left\"><code>42<\/code><\/td>\n<td style=\"text-align:left\">\u975e\u8d1f\u6574\u6570<\/td>\n<td style=\"text-align:left\">\u56fa\u5b9aPython\u3001NumPy\u3001PyTorch\u968f\u673a\u8fc7\u7a0b\uff1b\u8bbe0\u4e0d\u56fa\u5b9a\u3002\u67d0\u4e9bGPU\u7b97\u5b50\u4ecd\u53ef\u80fd\u6709\u672b\u4f4d\u5dee\u5f02\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n\n\n<h6 class=\"wp-block-heading\">CNN-RNN\u7ed3\u6784\u53c2\u6570<\/h6>\n\n\n\n<figure class=\"wp-block-table\"><table>\n<thead>\n<tr>\n<th style=\"text-align:left\">\u53c2\u6570<\/th>\n<th style=\"text-align:left\">\u9ed8\u8ba4\u503c<\/th>\n<th style=\"text-align:left\">\u5141\u8bb8\u53d6\u503c<\/th>\n<th style=\"text-align:left\">\u542b\u4e49\u4e0e\u8c03\u53c2\u5f71\u54cd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:left\"><code>networkType<\/code><\/td>\n<td style=\"text-align:left\"><code>&#039;LSTM&#039;<\/code><\/td>\n<td style=\"text-align:left\"><code>RNN\/LSTM\/GRU\/BiRNN\/BiLSTM\/BiGRU<\/code><\/td>\n<td style=\"text-align:left\">\u5faa\u73af\u7ed3\u6784\u3002\u666e\u901aRNN\u6700\u7b80\u5355\uff1bGRU\u8f83\u7cbe\u7b80\uff1b\u53cc\u5411\u7ed3\u6784\u540c\u65f6\u6c47\u603b\u4e24\u4e2a\u65b9\u5411\uff0c\u4f46\u8ba1\u7b97\u91cf\u66f4\u5927\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>convChannels<\/code><\/td>\n<td style=\"text-align:left\"><code>[32,64]<\/code><\/td>\n<td style=\"text-align:left\">\u6b63\u6574\u6570\u5e8f\u5217<\/td>\n<td style=\"text-align:left\">\u6bcf\u4e2a\u5377\u79ef\u5c42\u7684\u8f93\u51fa\u901a\u9053\u6570\uff0c\u5143\u7d20\u4e2a\u6570\u5373\u5377\u79ef\u5c42\u6570\u3002\u8c03\u5927\u53ef\u5b66\u4e60\u66f4\u591a\u6a21\u5f0f\uff0c\u4e5f\u66f4\u8017\u65f6\u3001\u66f4\u6613\u8fc7\u62df\u5408\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>kernelSize<\/code><\/td>\n<td style=\"text-align:left\"><code>5<\/code><\/td>\n<td style=\"text-align:left\">\u6b63\u5947\u6570<\/td>\n<td style=\"text-align:left\">\u5377\u79ef\u6838\u957f\u5ea6\u3002\u8d8a\u5927\u4e00\u6b21\u8986\u76d6\u7684\u76f8\u90bb\u4f4d\u7f6e\u8d8a\u591a\uff1b\u77ed\u5e8f\u5217\u901a\u5e38\u4f7f\u75283\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>poolSize<\/code><\/td>\n<td style=\"text-align:left\"><code>2<\/code><\/td>\n<td style=\"text-align:left\">\u6b63\u6574\u6570\uff0c\u4e0d\u8d85\u8fc7\u5e8f\u5217\u957f\u5ea6<\/td>\n<td style=\"text-align:left\">\u6700\u5927\u6c60\u5316\u7a97\u53e3\uff1b1\u8868\u793a\u4e0d\u6c60\u5316\u3002\u8fc7\u5ea6\u6c60\u5316\u4f1a\u4e22\u5931\u77ed\u5e8f\u5217\u4fe1\u606f\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>rnnHidden<\/code><\/td>\n<td style=\"text-align:left\"><code>64<\/code><\/td>\n<td style=\"text-align:left\">\u6b63\u6574\u6570<\/td>\n<td style=\"text-align:left\">\u5faa\u73af\u9690\u85cf\u5355\u5143\u6570\uff0c\u63a7\u5236\u8bb0\u5fc6\u5bb9\u91cf\u548c\u5206\u7c7b\u5934\u8f93\u5165\u7ef4\u5ea6\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>rnnLayers<\/code><\/td>\n<td style=\"text-align:left\"><code>1<\/code><\/td>\n<td style=\"text-align:left\">\u6b63\u6574\u6570<\/td>\n<td style=\"text-align:left\">\u5faa\u73af\u5c42\u5c42\u6570\uff1b\u5927\u4e8e1\u65f6\u5c42\u95f4\u4e5f\u5e94\u7528 <code>dropout<\/code>\u3002\u5c42\u6570\u589e\u52a0\u4f1a\u663e\u8457\u63d0\u9ad8\u8bad\u7ec3\u6210\u672c\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>dropout<\/code><\/td>\n<td style=\"text-align:left\"><code>0.20<\/code><\/td>\n<td style=\"text-align:left\"><code>[0,1)<\/code><\/td>\n<td style=\"text-align:left\">\u968f\u673a\u5931\u6d3b\u6bd4\u4f8b\u3002\u9002\u5f53\u589e\u5927\u53ef\u7f13\u89e3\u8fc7\u62df\u5408\uff0c\u8fc7\u5927\u4f1a\u6b20\u62df\u5408\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n\n\n<p>Python \u7248\u5faa\u73af\u7ed3\u6784\u5207\u6362\u793a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\">options[&#039;networkType&#039;] = &#039;RNN&#039;\noptions[&#039;networkType&#039;] = &#039;LSTM&#039;\noptions[&#039;networkType&#039;] = &#039;GRU&#039;\noptions[&#039;networkType&#039;] = &#039;BiRNN&#039;\noptions[&#039;networkType&#039;] = &#039;BiLSTM&#039;\noptions[&#039;networkType&#039;] = &#039;BiGRU&#039;<\/code><\/pre>\n\n\n\n<p>\u5b9e\u9645\u4f7f\u7528\u65f6\u53ea\u4fdd\u7559\u5176\u4e2d\u4e00\u884c\u3002\u53cc\u5411\u7ed3\u6784\u4f1a\u4f7f\u7528\u6b63\u5411\u672b\u7aef\u72b6\u6001\u4e0e\u53cd\u5411\u8d77\u70b9\u72b6\u6001\u62fc\u63a5\u540e\u5206\u7c7b\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">\u8bad\u7ec3\u53c2\u6570<\/h6>\n\n\n\n<figure class=\"wp-block-table\"><table>\n<thead>\n<tr>\n<th style=\"text-align:left\">\u53c2\u6570<\/th>\n<th style=\"text-align:left\">\u9ed8\u8ba4\u503c<\/th>\n<th style=\"text-align:left\">\u5141\u8bb8\u53d6\u503c<\/th>\n<th style=\"text-align:left\">\u542b\u4e49\u4e0e\u8c03\u53c2\u5f71\u54cd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:left\"><code>solverName<\/code><\/td>\n<td style=\"text-align:left\"><code>&#039;adam&#039;<\/code><\/td>\n<td style=\"text-align:left\"><code>&#039;adam&#039;\/&#039;sgdm&#039;\/&#039;rmsprop&#039;<\/code><\/td>\n<td style=\"text-align:left\">\u4f18\u5316\u5668\u3002Adam\u901a\u5e38\u9002\u5408\u4f5c\u4e3a\u521d\u59cb\u8bbe\u7f6e\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>maxEpochs<\/code><\/td>\n<td style=\"text-align:left\"><code>40<\/code><\/td>\n<td style=\"text-align:left\">\u6b63\u6574\u6570<\/td>\n<td style=\"text-align:left\">\u6700\u5927\u8bad\u7ec3\u8f6e\u6570\uff1b\u53ef\u80fd\u88ab\u65e9\u505c\u7f29\u77ed\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>learnRate<\/code><\/td>\n<td style=\"text-align:left\"><code>0.001<\/code><\/td>\n<td style=\"text-align:left\">\u6b63\u6570<\/td>\n<td style=\"text-align:left\">\u521d\u59cb\u5b66\u4e60\u7387\u3002\u592a\u5927\u53ef\u80fd\u9707\u8361\uff0c\u592a\u5c0f\u6536\u655b\u7f13\u6162\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>batchSize<\/code><\/td>\n<td style=\"text-align:left\"><code>64<\/code><\/td>\n<td style=\"text-align:left\">\u6b63\u6574\u6570<\/td>\n<td style=\"text-align:left\">\u6279\u5c3a\u5bf8\u3002\u5927\u6279\u6b21\u66f4\u7a33\u5b9a\u4f46\u5360\u66f4\u591a\u663e\u5b58\u6216\u5185\u5b58\uff1b\u5c0f\u6570\u636e\u53ef\u4f7f\u752816\u621632\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>earlyStoppingPatience<\/code><\/td>\n<td style=\"text-align:left\"><code>8<\/code><\/td>\n<td style=\"text-align:left\">\u975e\u8d1f\u6574\u6570<\/td>\n<td style=\"text-align:left\">\u9a8c\u8bc1\u635f\u5931\u8fde\u7eed\u591a\u5c11\u8f6e\u4e0d\u6539\u5584\u540e\u505c\u6b62\uff1b0\u5173\u95ed\u65e9\u505c\u3002\u6700\u4f73\u9a8c\u8bc1\u6743\u91cd\u4f1a\u88ab\u6062\u590d\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>learnRateSchedule<\/code><\/td>\n<td style=\"text-align:left\"><code>&#039;none&#039;<\/code><\/td>\n<td style=\"text-align:left\"><code>&#039;none&#039;\/&#039;piecewise&#039;<\/code><\/td>\n<td style=\"text-align:left\">\u662f\u5426\u6309\u56fa\u5b9a\u5468\u671f\u964d\u4f4e\u5b66\u4e60\u7387\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>learnRateDropPeriod<\/code><\/td>\n<td style=\"text-align:left\"><code>15<\/code><\/td>\n<td style=\"text-align:left\">\u6b63\u6574\u6570<\/td>\n<td style=\"text-align:left\"><code>piecewise<\/code> \u6a21\u5f0f\u4e2d\u6bcf\u9694\u591a\u5c11\u8f6e\u8870\u51cf\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>learnRateDropFactor<\/code><\/td>\n<td style=\"text-align:left\"><code>0.5<\/code><\/td>\n<td style=\"text-align:left\"><code>(0,1]<\/code><\/td>\n<td style=\"text-align:left\">\u5b66\u4e60\u7387\u8870\u51cf\u56e0\u5b50\u30020.5\u8868\u793a\u51cf\u534a\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>classWeight<\/code><\/td>\n<td style=\"text-align:left\"><code>&#039;auto&#039;<\/code><\/td>\n<td style=\"text-align:left\"><code>&#039;auto&#039;\/&#039;none&#039;<\/code> \u6216\u6b63\u6570\u5e8f\u5217<\/td>\n<td style=\"text-align:left\"><code>auto<\/code>\u53ea\u6839\u636e\u8bad\u7ec3\u96c6\u9891\u6570\u8ba1\u7b97\u7c7b\u522b\u6743\u91cd\uff1b\u81ea\u5b9a\u4e49\u6743\u91cd\u957f\u5ea6\u5fc5\u987b\u7b49\u4e8e\u7c7b\u522b\u6570\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>deviceSel<\/code><\/td>\n<td style=\"text-align:left\"><code>&#039;auto&#039;<\/code><\/td>\n<td style=\"text-align:left\"><code>&#039;auto&#039;\/&#039;cpu&#039;\/&#039;gpu&#039;<\/code><\/td>\n<td style=\"text-align:left\">\u8bad\u7ec3\u8bbe\u5907\u3002\u6307\u5b9aGPU\u4f46\u4e0d\u53ef\u7528\u65f6\u4f1a\u63d0\u793a\u5e76\u56de\u9000CPU\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n\n\n<h6 class=\"wp-block-heading\">\u6570\u636e\u5904\u7406\u4e0e\u7ed8\u56fe\u53c2\u6570<\/h6>\n\n\n\n<figure class=\"wp-block-table\"><table>\n<thead>\n<tr>\n<th style=\"text-align:left\">\u53c2\u6570<\/th>\n<th style=\"text-align:left\">\u9ed8\u8ba4\u503c<\/th>\n<th style=\"text-align:left\">\u5141\u8bb8\u53d6\u503c<\/th>\n<th style=\"text-align:left\">\u542b\u4e49\u4e0e\u6ce8\u610f\u4e8b\u9879<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:left\"><code>mapflag<\/code><\/td>\n<td style=\"text-align:left\"><code>True<\/code><\/td>\n<td style=\"text-align:left\"><code>True\/False<\/code><\/td>\n<td style=\"text-align:left\">\u662f\u5426\u6807\u51c6\u5316\u3002\u5747\u503c\u548c\u6807\u51c6\u5dee\u53ea\u4ece\u8bad\u7ec3\u96c6\u8ba1\u7b97\uff0c\u518d\u5e94\u7528\u5230\u9a8c\u8bc1\u548c\u6d4b\u8bd5\u6570\u636e\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>figflag<\/code><\/td>\n<td style=\"text-align:left\"><code>True<\/code><\/td>\n<td style=\"text-align:left\"><code>True\/False<\/code><\/td>\n<td style=\"text-align:left\">\u662f\u5426\u7ed8\u5236\u5e76\u4fdd\u5b58\u4e94\u5f20\u7ed3\u679c\u56fe\u3002\u6279\u91cf\u8c03\u53c2\u53ef\u5173\u95ed\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>showFigures<\/code><\/td>\n<td style=\"text-align:left\"><code>True<\/code><\/td>\n<td style=\"text-align:left\"><code>True\/False<\/code><\/td>\n<td style=\"text-align:left\">\u662f\u5426\u5c1d\u8bd5\u5f39\u51fa\u56fe\u7a97\uff1b\u56fe\u7247\u4ecd\u7531 <code>figflag<\/code> \u63a7\u5236\u4fdd\u5b58\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>caseName<\/code><\/td>\n<td style=\"text-align:left\"><code>&#039;CNN-RNN&#039;<\/code><\/td>\n<td style=\"text-align:left\">\u5b57\u7b26\u4e32<\/td>\n<td style=\"text-align:left\">\u56fe\u7247\u6587\u4ef6\u540d\u524d\u7f00\uff0c\u907f\u514d\u4e0d\u540cdemo\u8986\u76d6\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><code>classNames<\/code><\/td>\n<td style=\"text-align:left\"><code>None<\/code><\/td>\n<td style=\"text-align:left\">\u4e0e\u7c7b\u522b\u6570\u4e00\u81f4\u7684\u540d\u79f0\u5e8f\u5217<\/td>\n<td style=\"text-align:left\">\u7ed8\u56fe\u663e\u793a\u540d\uff0c\u987a\u5e8f\u5fc5\u987b\u4e0e\u6392\u5e8f\u540e\u7684\u539f\u59cb\u7c7b\u522b\u4e00\u81f4\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n\n\n<h6 class=\"wp-block-heading\">5. EvaClassEffect.py \u6587\u4ef6<\/h6>\n\n\n\n<p>\u8be5\u6587\u4ef6\u63d0\u4f9b\u72ec\u7acb\u8bc4\u4ef7\u51fd\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\">metrics = EvaClassEffect(realData, foreData, classOrder=None)<\/code><\/pre>\n\n\n\n<p>\u8f93\u5165\u771f\u5b9e\u7c7b\u522b\u3001\u9884\u6d4b\u7c7b\u522b\u548c\u53ef\u9009\u7c7b\u522b\u987a\u5e8f\uff0c\u8fd4\u56de Accuracy\u3001MacroPrecision\u3001MacroRecall\u3001MacroF1\u3001\u9010\u7c7b\u522b Precision\/Recall\/F1\u3001Support\u3001ConfusionMatrix \u4e0e ClassOrder\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">6. \u6570\u636e\u6587\u4ef6<\/h6>\n\n\n\n<ul>\n<li><code>iris.csv<\/code>\uff1aIris \u4e09\u5206\u7c7b\u6570\u636e\u3002<\/li>\n<li><code>har_activity_data.npz<\/code>\uff1aUCI HAR \u4e5d\u901a\u9053\u5e8f\u5217\u3001\u6807\u7b7e\u548c\u6309\u53d7\u8bd5\u8005\u9694\u79bb\u7684\u96c6\u5408\u6807\u8bb0\u3002<\/li>\n<li><code>mnist_subset.npz<\/code>\uff1aMNIST 0~9\u5341\u5206\u7c7b\u76845000\u5f20\u7070\u5ea6\u56fe\u5b50\u96c6\u3002<\/li>\n<li><code>\u6570\u636e\u6765\u6e90\u4e0e\u8bb8\u53ef.txt<\/code>\uff1a\u6570\u636e\u6765\u6e90\u4e0e\u8bb8\u53ef\u8bf4\u660e\uff1bUCI HAR \u6309 CC BY 4.0 \u4f7f\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<h6 class=\"wp-block-heading\">7. requirements.txt \u6587\u4ef6<\/h6>\n\n\n\n<p>\u8bb0\u5f55 NumPy\u3001Matplotlib\u3001scikit-learn \u548c PyTorch \u7b49\u4f9d\u8d56\u7248\u672c\u3002\u5efa\u8bae\u5148\u5728\u72ec\u7acbPython 3.11\u73af\u5883\u4e2d\u5b89\u88c5\uff0c\u518d\u8fd0\u884cdemo\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">8. figure \u6587\u4ef6\u5939<\/h6>\n\n\n\n<p>\u6bcf\u4e2ademo\u751f\u62105\u5f20\u72ec\u7acbPNG\uff0c\u4e09\u4e2a\u6848\u4f8b\u517115\u5f20\uff1a\u6536\u655b\u8fc7\u7a0b\u3001\u6d4b\u8bd5\u96c6\u6df7\u6dc6\u77e9\u9635\u3001\u5404\u7c7b\u522b\u6307\u6807\u3001\u6d4b\u8bd5\u96c6\u7c7b\u522b\u5bf9\u6bd4\u3001\u8bad\u7ec3\/\u9a8c\u8bc1\/\u6d4b\u8bd5\u6307\u6807\u5bf9\u6bd4\u3002\u5b8c\u6574\u7248\u56fe\u7247\u65e0\u6c34\u5370\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">9. \u4ee3\u7801\u8bf4\u660e.txt \u6587\u4ef6<\/h6>\n\n\n\n<p>\u968f\u4ee3\u7801\u4ea4\u4ed8\u7684\u79bb\u7ebf\u624b\u518c\uff0c\u5b8c\u6574\u5c55\u5f00\u8f93\u5165\u3001\u8f93\u51fa\u3001<code>options<\/code>\u3001\u6570\u636e\u66ff\u6362\u65b9\u5f0f\u3001\u8fd0\u884c\u73af\u5883\u4e0e\u5e38\u89c1\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e09\u3001\u5feb\u901f\u5f00\u59cb<\/h4>\n\n\n\n<h6 class=\"wp-block-heading\">1. \u521b\u5efa\u73af\u5883\u5e76\u5b89\u88c5\u4f9d\u8d56<\/h6>\n\n\n\n<p>\u5efa\u8bae\u521b\u5efa Python 3.11 \u73af\u5883\uff0c\u7136\u540e\u5728\u4ee3\u7801\u6587\u4ef6\u5939\u6267\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-bash\">pip install -r requirements.txt<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">2. \u8fd0\u884c\u4e0e\u81ea\u5df1\u6570\u636e\u5f62\u6001\u6700\u63a5\u8fd1\u7684demo<\/h6>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-bash\">python demoCNNRNNClassIris.py\npython demoCNNRNNClassHAR.py\npython demoCNNRNNClassMNIST.py<\/code><\/pre>\n\n\n\n<p>\u9009\u62e9\u5176\u4e2d\u4e00\u4e2a\u5373\u53ef\u3002\u7a0b\u5e8f\u65e0\u62a5\u9519\u3001\u547d\u4ee4\u884c\u6253\u5370\u4e09\u96c6\u5408\u6307\u6807\u3001<code>figure\/<\/code> \u751f\u62105\u5f20\u56fe\u7247\uff0c\u5373\u8bf4\u660e\u8fd0\u884c\u73af\u5883\u6b63\u5e38\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">3. \u66ff\u6362\u6210\u81ea\u5df1\u7684\u6570\u636e<\/h6>\n\n\n\n<p>\u4e8c\u7ef4\u4e00\u7ef4\u6570\u7ec4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\">data = np.loadtxt(&#039;your_data.csv&#039;, delimiter=&#039;,&#039;)\nX = data[:, :-1]\nY = data[:, -1]\noptions[&#039;sequenceAxis&#039;] = 0<\/code><\/pre>\n\n\n\n<p>\u591a\u901a\u9053\u5e8f\u5217\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># X.shape = [\u6837\u672c\u6570, \u901a\u9053\u6570, \u65f6\u95f4\u957f\u5ea6]\n# Y.shape = [\u6837\u672c\u6570]\noptions[&#039;sequenceAxis&#039;] = 1<\/code><\/pre>\n\n\n\n<p>\u7070\u5ea6\u56fe\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># X.shape = [\u6837\u672c\u6570, \u9ad8\u5ea6, \u5bbd\u5ea6]\n# Y.shape = [\u6837\u672c\u6570]\noptions[&#039;sequenceAxis&#039;] = 1  # \u6cbf\u5bbd\u5ea6\u9010\u5217\u8bfb\u53d6<\/code><\/pre>\n\n\n\n<p>\u5f69\u8272\u56fe\u53ef\u6574\u7406\u4e3a <code>[\u6837\u672c\u6570,\u901a\u9053\u6570,\u9ad8\u5ea6,\u5bbd\u5ea6]<\/code>\uff0c\u6cbf\u5bbd\u5ea6\u8bfb\u53d6\u65f6\u8bbe\u7f6e <code>sequenceAxis=2<\/code>\uff0c\u901a\u9053\u548c\u9ad8\u5ea6\u4f1a\u5408\u5e76\u4e3a\u6bcf\u4e00\u6b65\u7684\u7279\u5f81\u3002\u82e5\u4efb\u52a1\u5f3a\u4f9d\u8d56\u4e8c\u7ef4\u5c40\u90e8\u90bb\u57df\uff0c\u6807\u51c6\u4e8c\u7ef4CNN\u901a\u5e38\u66f4\u5408\u9002\uff1bCNN-RNN\u66f4\u9002\u5408\u67d0\u4e2a\u65b9\u5411\u5177\u6709\u660e\u786e\u626b\u63cf\u6216\u5e8f\u5217\u542b\u4e49\u7684\u573a\u666f\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">4. \u907f\u514d\u6570\u636e\u6cc4\u6f0f<\/h6>\n\n\n\n<p>\u540c\u4e00\u53d7\u8bd5\u8005\u3001\u8bbe\u5907\u6216\u6279\u6b21\u4ea7\u751f\u7684\u591a\u6761\u6837\u672c\u4e0d\u5e94\u968f\u673a\u6563\u843d\u5728\u4e09\u4e2a\u96c6\u5408\u3002\u53ef\u4ee5\u81ea\u5df1\u6784\u9020\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\">options[&#039;splitLabels&#039;] = split_labels  # 1\u8bad\u7ec3\u30012\u9a8c\u8bc1\u30013\u6d4b\u8bd5<\/code><\/pre>\n\n\n\n<p>\u7a0b\u5e8f\u7684\u6807\u51c6\u5316\u5668\u53ea\u4ece\u8bad\u7ec3\u96c6\u62df\u5408\uff0c\u4f46\u524d\u63d0\u662f\u96c6\u5408\u5212\u5206\u672c\u8eab\u5408\u7406\u3002\u9519\u8bef\u5212\u5206\u9020\u6210\u7684\u6cc4\u6f0f\u4e0d\u80fd\u9760\u6a21\u578b\u53c2\u6570\u4fee\u590d\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">5. \u8c03\u53c2\u4e0e\u8fd0\u884c<\/h6>\n\n\n\n<p>\u5148\u56fa\u5b9a\u6570\u636e\u5212\u5206\uff0c\u518d\u4f9d\u6b21\u68c0\u67e5\u5e8f\u5217\u8f74\u3001\u7f51\u7edc\u5bb9\u91cf\u548c\u8bad\u7ec3\u8282\u594f\u3002\u8bad\u7ec3\u96c6\u663e\u8457\u4f18\u4e8e\u9a8c\u8bc1\u96c6\u65f6\uff0c\u53ef\u4ee5\u51cf\u5c0f <code>convChannels<\/code>\u3001<code>rnnHidden<\/code> \u6216 <code>rnnLayers<\/code>\uff0c\u589e\u5927 <code>dropout<\/code>\uff0c\u4e5f\u53ef\u4ee5\u589e\u52a0\u6570\u636e\u548c\u6539\u8fdb\u5206\u7ec4\u5212\u5206\u3002\u635f\u5931\u5267\u70c8\u9707\u8361\u65f6\u4f18\u5148\u964d\u4f4e <code>learnRate<\/code>\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u56db\u3001\u5173\u4e8e\u5b8c\u6574\u7248\u4e0e\u516c\u5f00\u7248\u4ee3\u7801<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table>\n<thead>\n<tr>\n<th style=\"text-align:left\">\u529f\u80fd<\/th>\n<th style=\"text-align:center\">\u5b8c\u6574\u7248<\/th>\n<th style=\"text-align:center\">\u516c\u5f00\u7248<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:left\">Iris\u4e00\u7ef4\u7279\u5f81\u6f14\u793a<\/td>\n<td style=\"text-align:center\">\u221a<\/td>\n<td style=\"text-align:center\">\u221a\uff0c90\u6761<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">HAR\u591a\u901a\u9053\u5e8f\u5217\u6f14\u793a<\/td>\n<td style=\"text-align:center\">\u221a<\/td>\n<td style=\"text-align:center\">\u221a\uff0c96\u6761<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">MNIST\u56fe\u50cf\u6f14\u793a<\/td>\n<td style=\"text-align:center\">0~9\u5341\u5206\u7c7b\uff0c5000\u5f20<\/td>\n<td style=\"text-align:center\">0\/1\/2\u4e09\u5206\u7c7b\uff0c90\u5f20<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">\u81ea\u5b9a\u4e49\u6570\u636e\u4e0e\u53c2\u6570<\/td>\n<td style=\"text-align:center\">\u221a<\/td>\n<td style=\"text-align:center\">\u221a<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">\u6838\u5fc3\u51fd\u6570\u6e90\u7801<\/td>\n<td style=\"text-align:center\">\u63d0\u4f9b<\/td>\n<td style=\"text-align:center\">\u4e0d\u63d0\u4f9b<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">\u6700\u5927\u6837\u672c\u6570<\/td>\n<td style=\"text-align:center\">\u65e0\u4eba\u5de5\u9650\u5236\uff0c\u53d7\u786c\u4ef6\u7ea6\u675f<\/td>\n<td style=\"text-align:center\">100\u6761<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">\u6700\u5927\u5377\u79ef\u5c42\u6570<\/td>\n<td style=\"text-align:center\">\u65e0\u8bd5\u7528\u7248\u9650\u5236<\/td>\n<td style=\"text-align:center\">2\u5c42<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">\u6700\u5927\u8bad\u7ec3\u8f6e\u6570<\/td>\n<td style=\"text-align:center\">\u65e0\u8bd5\u7528\u7248\u9650\u5236<\/td>\n<td style=\"text-align:center\">30\u8f6e<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">\u5faa\u73af\u5c42\u6570<\/td>\n<td style=\"text-align:center\">\u53ef\u8bbe\u7f6e<\/td>\n<td style=\"text-align:center\">1\u5c42<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">\u5faa\u73af\u7ed3\u6784<\/td>\n<td style=\"text-align:center\">RNN\u3001LSTM\u3001GRU\u3001BiRNN\u3001BiLSTM\u3001BiGRU<\/td>\n<td style=\"text-align:center\">LSTM\u3001GRU<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">\u6700\u5927\u9690\u85cf\u5355\u5143\u6570<\/td>\n<td style=\"text-align:center\">\u65e0\u8bd5\u7528\u7248\u9650\u5236<\/td>\n<td style=\"text-align:center\">64<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">\u81ea\u52a8\u5206\u7c7b\u6307\u6807\u548c15\u5f20\u6848\u4f8b\u56fe<\/td>\n<td style=\"text-align:center\">\u221a<\/td>\n<td style=\"text-align:center\">\u221a<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">\u7ed3\u679c\u56fe\u6c34\u5370<\/td>\n<td style=\"text-align:center\">\u65e0\u6c34\u5370<\/td>\n<td style=\"text-align:center\">\u6709\u201c\u8bd5\u7528\u7248@khsci.com\/docs\u201d\u6c34\u5370<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\">\u4fee\u6539\u6838\u5fc3\u5b9e\u73b0\u4e0e\u4e8c\u6b21\u5f00\u53d1<\/td>\n<td style=\"text-align:center\">\u221a<\/td>\n<td style=\"text-align:center\">\u00d7<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n\n\n<p>\u516c\u5f00\u7248\u7528\u4e8e\u9a8c\u8bc1 Python \u73af\u5883\u3001\u7406\u89e3\u8f93\u5165\u683c\u5f0f\u548c\u4f53\u9a8c\u5b8c\u6574\u8c03\u7528\u6d41\u7a0b\uff1b\u6b63\u5f0f\u8bad\u7ec3\u3001\u5927\u6570\u636e\u4efb\u52a1\u4e0e\u4e8c\u6b21\u5f00\u53d1\u5efa\u8bae\u4f7f\u7528\u5b8c\u6574\u7248\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e94\u3001\u83b7\u53d6\u516c\u5f00\u7248\u7a0b\u5e8f<\/h4>\n\n\n\n<blockquote class=\"wp-block-quote\">\n<p><strong>\u516c\u5f00\u7248\u4e0b\u8f7d\uff1a<\/strong> <a href=\"https:\/\/www.khsci.com\/docs\/wp-content\/uploads\/2026\/07\/cnn-rnn-classification-python-trial-v26wq012h.zip\">\u70b9\u51fb\u6b64\u5904\u4e0b\u8f7d CNN-RNN \u901a\u7528\u5206\u7c7b Python \u516c\u5f00\u7248\u4ee3\u7801<\/a><\/p>\n<\/blockquote>\n\n\n\n<p>\u6ce8\uff1a\u516c\u5f00\u7248\u9002\u7528\u4e8e Windows 64\u4f4d Python 3.11\uff0c\u6700\u591a\u652f\u6301100\u6761\u6837\u672c\uff0c\u6700\u591a\u8bad\u7ec330\u8f6e\uff0c\u7ed3\u679c\u56fe\u5e26\u8bd5\u7528\u7248\u6c34\u5370\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u516d\u3001\u83b7\u53d6\u5b8c\u6574\u7248\u7a0b\u5e8f<\/h4>\n\n\n\n<p>\u70b9\u51fb\u672c\u9875\u9762\u201c\u7acb\u5373\u652f\u4ed8\u201d\u6309\u94ae\uff0c\u4ed8\u6b3e\u540e\u83b7\u53d6\u5b8c\u6574\u7248\u4ee3\u7801\u4e0b\u8f7d\u94fe\u63a5\u548c\u552e\u540e\u8054\u7cfb\u65b9\u5f0f\u3002\u4ed8\u6b3e\u5b8c\u6210\u540e\u5237\u65b0\u672c\u9875\u9762\u5373\u53ef\u770b\u5230\u4e0b\u8f7d\u94fe\u63a5\u3002<\/p>\n\n\n\n<p>\uff08\u6ce8\u610f\u652f\u4ed8\u8df3\u8f6c\u5931\u8d25\u7684\u8bdd\uff0c\u8bf7\u4f7f\u7528\u6d4f\u89c8\u5668\u6253\u5f00\u672c\u9875\u9762\uff09<\/p>\n\n\n<p><div class=\"erphp-wppay\">\n\t\t\t\t\u60a8\u9700\u8981\u5148\u652f\u4ed8 <b>69.5\u5143<\/b> \u624d\u80fd\u67e5\u770b\u6b64\u5904\u5185\u5bb9\uff01<a href=\"javascript:;\" class=\"erphp-wppay-loader\" data-post=\"3904\">\u7acb\u5373\u652f\u4ed8<\/a>\n\t\t\t<\/div><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e03\u3001\u5b8c\u6574\u7248\u4ee3\u7801\u91cd\u8981\u66f4\u65b0<\/h4>\n\n\n\n<ul>\n<li>20260720\uff1a\u5b8c\u6210 Python \u7248\u521d\u7248\u4ee3\u7801\uff0c\u652f\u6301\u4e00\u7ef4\u6570\u7ec4\u3001\u591a\u901a\u9053\u5e8f\u5217\u3001\u7070\u5ea6\u56fe\u548c\u66f4\u9ad8\u7ef4\u8f93\u5165\u9002\u914d\uff1b\u652f\u6301\u516d\u79cd\u5faa\u73af\u7ed3\u6784\uff0c\u63d0\u4f9b Iris\u3001UCI HAR\u3001MNIST \u4e09\u4e2a\u6848\u4f8b\u548c15\u5f20\u81ea\u52a8\u7ed3\u679c\u56fe\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u516b\u3001\u5e38\u89c1\u95ee\u9898<\/h4>\n\n\n\n<h6 class=\"wp-block-heading\">Q1\uff1a\u4e3a\u4ec0\u4e48\u8bf4\u662f\u201c\u901a\u7528\u5206\u7c7b\u201d\uff0c\u4f46\u8fd8\u8981\u6307\u5b9a sequenceAxis\uff1f<\/h6>\n\n\n\n<p>\u201c\u901a\u7528\u201d\u6307\u51fd\u6570\u80fd\u9002\u914d\u591a\u79cd\u6570\u7ec4\u7ef4\u5ea6\uff0c\u4e0d\u4ee3\u8868\u6a21\u578b\u4e0d\u9700\u8981\u7ed3\u6784\u5047\u8bbe\u3002CNN\u548cRNN\u5fc5\u987b\u77e5\u9053\u6cbf\u54ea\u4e2a\u65b9\u5411\u5bfb\u627e\u76f8\u90bb\u6a21\u5f0f\u548c\u524d\u540e\u5173\u7cfb\uff0c\u56e0\u6b64\u7528\u6237\u4ecd\u9700\u660e\u786e\u5e8f\u5217\u8f74\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Q2\uff1a\u6240\u6709\u666e\u901a\u8868\u683c\u6570\u636e\u90fd\u9002\u5408\u5417\uff1f<\/h6>\n\n\n\n<p>\u4e0d\u4e00\u5b9a\u3002\u666e\u901a\u8868\u683c\u7684\u5217\u5982\u679c\u6ca1\u6709\u7a33\u5b9a\u7684\u987a\u5e8f\u548c\u90bb\u63a5\u542b\u4e49\uff0cCNN-RNN\u867d\u7136\u80fd\u8fd0\u884c\uff0c\u4f46\u7ed3\u6784\u4f18\u52bf\u53ef\u80fd\u53d1\u6325\u4e0d\u51fa\u6765\u3002\u5e94\u4e0e\u6811\u6a21\u578b\u3001SVM\u3001\u5168\u8fde\u63a5\u7f51\u7edc\u7b49\u57fa\u7ebf\u6bd4\u8f83\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Q3\uff1a\u516c\u5f00\u7248\u62a5\u9519\u627e\u4e0d\u5230 FunClassCNNRNN \u600e\u4e48\u529e\uff1f<\/h6>\n\n\n\n<p>\u5148\u786e\u8ba4\u4f7f\u7528 Windows 64\u4f4d Python 3.11\uff0c\u5e76\u4e14\u4ece\u516c\u5f00\u7248\u4ee3\u7801\u6587\u4ef6\u5939\u8fd0\u884cdemo\u3002\u5176\u4ed6Python\u5927\u7248\u672c\u65e0\u6cd5\u76f4\u63a5\u52a0\u8f7d\u8be5\u516c\u5f00\u7248\u6838\u5fc3\u6a21\u5757\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Q4\uff1a\u6307\u5b9aGPU\u540e\u4e3a\u4ec0\u4e48\u4ecd\u7136\u4f7f\u7528CPU\uff1f<\/h6>\n\n\n\n<p>\u5f53\u524d PyTorch \u5fc5\u987b\u5b9e\u9645\u68c0\u6d4b\u5230\u53ef\u7528CUDA\u8bbe\u5907\u3002\u82e5\u5b89\u88c5\u7684\u662fCPU\u7248PyTorch\uff0c\u6216CUDA\u4e0e\u9a71\u52a8\u4e0d\u5339\u914d\uff0c\u7a0b\u5e8f\u4f1a\u63d0\u793a\u5e76\u56de\u9000CPU\u3002\u53ef\u5148\u8fd0\u884c <code>torch.cuda.is_available()<\/code> \u68c0\u67e5\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Q5\uff1a\u8bad\u7ec3\u96c6\u5f88\u597d\uff0c\u6d4b\u8bd5\u96c6\u8f83\u5dee\u600e\u4e48\u529e\uff1f<\/h6>\n\n\n\n<p>\u5148\u68c0\u67e5\u5206\u7ec4\u6cc4\u6f0f\u548c\u7c7b\u522b\u6bd4\u4f8b\uff0c\u518d\u6bd4\u8f83\u9a8c\u8bc1\u96c6\u8d70\u52bf\u3002\u53ef\u4ee5\u51cf\u5c0f\u7f51\u7edc\u3001\u589e\u52a0Dropout\u3001\u4f7f\u7528\u65e9\u505c\u3001\u589e\u52a0\u6570\u636e\u6216\u8c03\u6574\u5212\u5206\u3002\u4e0d\u8981\u5728\u6d4b\u8bd5\u96c6\u4e0a\u53cd\u590d\u8c03\u53c2\uff1b\u6d4b\u8bd5\u96c6\u5e94\u7559\u5230\u6700\u540e\u8bc4\u4f30\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Q6\uff1a\u6700\u5c11\u9700\u8981\u4fee\u6539\u54ea\u4e9b\u5185\u5bb9\uff1f<\/h6>\n\n\n\n<p>\u6700\u5c11\u66ff\u6362 <code>X<\/code>\u3001<code>Y<\/code> \u548c <code>options[&#039;sequenceAxis&#039;]<\/code>\u3002\u5982\u679c\u6837\u672c\u5b58\u5728\u4eba\u5458\u3001\u8bbe\u5907\u6216\u6279\u6b21\u5173\u8054\uff0c\u518d\u63d0\u4f9b <code>splitLabels<\/code>\u3002\u4e4b\u540e\u6839\u636e\u9a8c\u8bc1\u96c6\u8868\u73b0\u8c03\u6574\u7f51\u7edc\u4e0e\u8bad\u7ec3\u53c2\u6570\u3002<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u4ecb\u7ecd\u4e00\u5957\u57fa\u4e8e PyTorch \u7684 CNN-RNN \u901a\u7528\u5206\u7c7b\u4ee3\u7801\u3002\u6838\u5fc3\u51fd\u6570\u4f1a\u5728\u6bcf\u6761\u6837\u672c\u5185\u90e8\u9009\u62e9\u4e00\u4e2a\u201c\u5e8f\u5217\u8f74\u201d [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.13 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CNN-RNN\u901a\u7528\u5206\u7c7bPython\u4ee3\u7801 - \u5de5\u5177\u7bb1\u6587\u6863<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CNN-RNN\u901a\u7528\u5206\u7c7bPython\u4ee3\u7801 - \u5de5\u5177\u7bb1\u6587\u6863\" \/>\n<meta property=\"og:description\" content=\"\u672c\u6587\u4ecb\u7ecd\u4e00\u5957\u57fa\u4e8e PyTorch \u7684 CNN-RNN \u901a\u7528\u5206\u7c7b\u4ee3\u7801\u3002\u6838\u5fc3\u51fd\u6570\u4f1a\u5728\u6bcf\u6761\u6837\u672c\u5185\u90e8\u9009\u62e9\u4e00\u4e2a\u201c\u5e8f\u5217\u8f74\u201d [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/\" \/>\n<meta property=\"og:site_name\" content=\"\u5de5\u5177\u7bb1\u6587\u6863\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-27T23:39:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.khsci.com\/docs\/wp-content\/uploads\/2026\/07\/cnn-rnn-classification-python-iris-confusion.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"CNN-RNN\u901a\u7528\u5206\u7c7bPython\u4ee3\u7801\",\"datePublished\":\"2026-07-27T23:39:49+00:00\",\"dateModified\":\"2026-07-27T23:39:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/\"},\"wordCount\":176,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.khsci.com\/docs\/#\/schema\/person\/44b1dc94a273203f641349de36ebc0a5\"},\"articleSection\":[\"\u6a21\u5f0f\u8bc6\u522b\/\u5206\u7c7b\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/\",\"url\":\"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/\",\"name\":\"CNN-RNN\u901a\u7528\u5206\u7c7bPython\u4ee3\u7801 - \u5de5\u5177\u7bb1\u6587\u6863\",\"isPartOf\":{\"@id\":\"https:\/\/www.khsci.com\/docs\/#website\"},\"datePublished\":\"2026-07-27T23:39:49+00:00\",\"dateModified\":\"2026-07-27T23:39:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.khsci.com\/docs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CNN-RNN\u901a\u7528\u5206\u7c7bPython\u4ee3\u7801\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.khsci.com\/docs\/#website\",\"url\":\"https:\/\/www.khsci.com\/docs\/\",\"name\":\"\u5de5\u5177\u7bb1\u6587\u6863\",\"description\":\"khToolbox\",\"publisher\":{\"@id\":\"https:\/\/www.khsci.com\/docs\/#\/schema\/person\/44b1dc94a273203f641349de36ebc0a5\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.khsci.com\/docs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.khsci.com\/docs\/#\/schema\/person\/44b1dc94a273203f641349de36ebc0a5\",\"name\":\"kuohao\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.khsci.com\/docs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/khsci.com\/docs\/wp-content\/uploads\/2022\/11\/logo-1.png\",\"contentUrl\":\"https:\/\/khsci.com\/docs\/wp-content\/uploads\/2022\/11\/logo-1.png\",\"width\":255,\"height\":97,\"caption\":\"kuohao\"},\"logo\":{\"@id\":\"https:\/\/www.khsci.com\/docs\/#\/schema\/person\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CNN-RNN\u901a\u7528\u5206\u7c7bPython\u4ee3\u7801 - \u5de5\u5177\u7bb1\u6587\u6863","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/","og_locale":"zh_CN","og_type":"article","og_title":"CNN-RNN\u901a\u7528\u5206\u7c7bPython\u4ee3\u7801 - \u5de5\u5177\u7bb1\u6587\u6863","og_description":"\u672c\u6587\u4ecb\u7ecd\u4e00\u5957\u57fa\u4e8e PyTorch \u7684 CNN-RNN \u901a\u7528\u5206\u7c7b\u4ee3\u7801\u3002\u6838\u5fc3\u51fd\u6570\u4f1a\u5728\u6bcf\u6761\u6837\u672c\u5185\u90e8\u9009\u62e9\u4e00\u4e2a\u201c\u5e8f\u5217\u8f74\u201d [&hellip;]","og_url":"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/","og_site_name":"\u5de5\u5177\u7bb1\u6587\u6863","article_published_time":"2026-07-27T23:39:49+00:00","og_image":[{"url":"https:\/\/www.khsci.com\/docs\/wp-content\/uploads\/2026\/07\/cnn-rnn-classification-python-iris-confusion.png"}],"twitter_card":"summary_large_image","twitter_misc":{"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/#article","isPartOf":{"@id":"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/"},"author":{"name":"","@id":""},"headline":"CNN-RNN\u901a\u7528\u5206\u7c7bPython\u4ee3\u7801","datePublished":"2026-07-27T23:39:49+00:00","dateModified":"2026-07-27T23:39:49+00:00","mainEntityOfPage":{"@id":"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/"},"wordCount":176,"commentCount":0,"publisher":{"@id":"https:\/\/www.khsci.com\/docs\/#\/schema\/person\/44b1dc94a273203f641349de36ebc0a5"},"articleSection":["\u6a21\u5f0f\u8bc6\u522b\/\u5206\u7c7b"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/","url":"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/","name":"CNN-RNN\u901a\u7528\u5206\u7c7bPython\u4ee3\u7801 - \u5de5\u5177\u7bb1\u6587\u6863","isPartOf":{"@id":"https:\/\/www.khsci.com\/docs\/#website"},"datePublished":"2026-07-27T23:39:49+00:00","dateModified":"2026-07-27T23:39:49+00:00","breadcrumb":{"@id":"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.khsci.com\/docs\/index.php\/2026\/07\/28\/cnn-rnn-classification-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.khsci.com\/docs\/"},{"@type":"ListItem","position":2,"name":"CNN-RNN\u901a\u7528\u5206\u7c7bPython\u4ee3\u7801"}]},{"@type":"WebSite","@id":"https:\/\/www.khsci.com\/docs\/#website","url":"https:\/\/www.khsci.com\/docs\/","name":"\u5de5\u5177\u7bb1\u6587\u6863","description":"khToolbox","publisher":{"@id":"https:\/\/www.khsci.com\/docs\/#\/schema\/person\/44b1dc94a273203f641349de36ebc0a5"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.khsci.com\/docs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/www.khsci.com\/docs\/#\/schema\/person\/44b1dc94a273203f641349de36ebc0a5","name":"kuohao","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.khsci.com\/docs\/#\/schema\/person\/image\/","url":"https:\/\/khsci.com\/docs\/wp-content\/uploads\/2022\/11\/logo-1.png","contentUrl":"https:\/\/khsci.com\/docs\/wp-content\/uploads\/2022\/11\/logo-1.png","width":255,"height":97,"caption":"kuohao"},"logo":{"@id":"https:\/\/www.khsci.com\/docs\/#\/schema\/person\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.khsci.com\/docs\/index.php\/wp-json\/wp\/v2\/posts\/3904"}],"collection":[{"href":"https:\/\/www.khsci.com\/docs\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.khsci.com\/docs\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/www.khsci.com\/docs\/index.php\/wp-json\/wp\/v2\/comments?post=3904"}],"version-history":[{"count":1,"href":"https:\/\/www.khsci.com\/docs\/index.php\/wp-json\/wp\/v2\/posts\/3904\/revisions"}],"predecessor-version":[{"id":3906,"href":"https:\/\/www.khsci.com\/docs\/index.php\/wp-json\/wp\/v2\/posts\/3904\/revisions\/3906"}],"wp:attachment":[{"href":"https:\/\/www.khsci.com\/docs\/index.php\/wp-json\/wp\/v2\/media?parent=3904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.khsci.com\/docs\/index.php\/wp-json\/wp\/v2\/categories?post=3904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.khsci.com\/docs\/index.php\/wp-json\/wp\/v2\/tags?post=3904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}