{"id":158437,"date":"2019-09-28T12:30:04","date_gmt":"2019-09-28T04:30:04","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=158437"},"modified":"2019-09-24T20:51:14","modified_gmt":"2019-09-24T12:51:14","slug":"keras-tensorflow","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/keras-tensorflow.html","title":{"rendered":"Keras 2.3.0 \u53d1\u5e03\uff1a\u652f\u6301TensorFlow 2.0"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6628\u5929\uff0cKeras\u56e2\u961f\u5ba3\u5e03\u53d1\u5e03Keras 2.3.0\uff0c\u8fd9\u662f\u7b2c\u4e00\u4e2a\u652f\u6301TensorFlow 2.0\u7684\u591a\u540e\u7aefKeras\u7248\u672c\u3002\u8fd9\u4e5f\u662f\u591a\u540e\u7aefKeras\u7684\u6700\u540e\u4e00\u4e2a\u4e3b\u8981\u7248\u672c\u3002\u5b83\u4e0eTensorFlow 1.14,1.13\uff0cTheano\u548cCNTK\u5411\u540e\u517c\u5bb9\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
Keras\u4e3b\u8981\u5173\u6ce8tf.keras\uff0c\u540c\u65f6\u7ee7\u7eed\u652f\u6301Theano\/CNTK<\/strong><\/div>\n

\u6b64\u7248\u672c\u9644\u5e26\u4e86\u8bb8\u591aAPI\u66f4\u6539\uff0c\u4ee5\u4f7f\u591a\u540e\u7aefKeras API\u4e0eTensorFlow\u7684\u9ad8\u7ea7API tf.keras\u201c\u540c\u6b65\u201d\u3002\u4f46\u662f\uff0c\u6709\u4e9bTensorFlow 2.0\u529f\u80fd\u4e0d\u53d7\u652f\u6301\u3002\u8fd9\u5c31\u662f\u56e2\u961f\u5efa\u8bae\u5f00\u53d1\u4eba\u5458\u5728TensorFlow 2.0\u4e2d\u5c06\u4ed6\u4eec\u7684Keras\u4ee3\u7801\u5207\u6362\u5230tf.keras\u7684\u539f\u56e0\u3002<\/p>\n

\u8fc1\u79fb\u5230tf.keras\u5c06\u4f7f\u5f00\u53d1\u4eba\u5458\u80fd\u591f\u8bbf\u95ee\u8bf8\u5982\u5feb\u901f\u6267\u884c\uff0cTPU\u57f9\u8bad\u4ee5\u53ca\u4f4e\u7ea7TensorFlow\u4e0eLayer\u548cModel\u7b49\u9ad8\u7ea7\u6982\u5ff5\u4e4b\u95f4\u66f4\u597d\u7684\u96c6\u6210\u3002<\/p>\n

\u5728\u6b64\u7248\u672c\u53d1\u5e03\u540e\uff0c\u8be5\u56e2\u961f\u8ba1\u5212\u4e3b\u8981\u5173\u6ce8tf.keras\u7684\u8fdb\u4e00\u6b65\u53d1\u5c55\u3002 \u201c\u53d1\u5c55\u5c06\u91cd\u70b9\u5173\u6ce8\u672a\u6765\u7684\u53d1\u5c55\u3002\u6211\u4eec\u5c06\u5728\u672a\u67656\u4e2a\u6708\u5185\u7ee7\u7eed\u7ef4\u62a4\u591a\u540e\u7aefKeras\uff0c\u4f46\u6211\u4eec\u53ea\u4f1a\u5408\u5e76\u9519\u8bef\u4fee\u590d\u3002 API\u66f4\u6539\u5c06\u4e0d\u4f1a\u88ab\u79fb\u690d\uff0c\u201c\u8be5\u56e2\u961f\u5199\u9053\u3002<\/p>\n

\u4e3a\u4e86\u8ba9\u793e\u533a\u66f4\u5bb9\u6613\u4e3aKeras\u7684\u5f00\u53d1\u505a\u51fa\u8d21\u732e\uff0c\u8be5\u56e2\u961f\u5c06\u5728keras-team\/keras\u7684\u72ec\u7acbGitHub\u5b58\u50a8\u5e93\u4e2d\u5f00\u53d1tf.keras\u3002<\/p>\n

<\/p>\n

Keras 2.3.0\u4e2d\u7684API\u66f4\u65b0<\/strong><\/div>\n

<\/strong><\/p>\n

\u4ee5\u4e0b\u662fKeras 2.3.0\u4e2d\u7684\u4e00\u4e9bAPI\u66f4\u65b0\uff1a<\/p>\n

add_metric\u65b9\u6cd5\u88ab\u6dfb\u52a0\u5230Layer\/Model\uff0c\u5b83\u7c7b\u4f3c\u4e8eadd_loss\u65b9\u6cd5\uff0c\u4f46\u662f\u7528\u4e8e\u6307\u6807\u3002<\/p>\n

Keras 2.3.0\u5f15\u5165\u4e86\u51e0\u4e2a\u57fa\u4e8e\u7c7b\u7684\u4e22\u5931\uff0c\u5305\u62ecMeanSquaredError\uff0cMeanAbsoluteError\uff0cBinaryCrossentropy\uff0cHinge\u7b49\u3002\u901a\u8fc7\u6b64\u66f4\u65b0\uff0c\u53ef\u4ee5\u901a\u8fc7\u6784\u9020\u51fd\u6570\u53c2\u6570\u6765\u53c2\u6570\u5316\u4e22\u5931\u3002<\/p>\n

\u6dfb\u52a0\u4e86\u8bb8\u591a\u57fa\u4e8e\u7c7b\u7684\u5ea6\u91cf\u6807\u51c6\uff0c\u5305\u62ecAccuracy\uff0cMeanSquaredError\uff0cHinge\uff0cFalsePositives\uff0cBinaryAccuracy\u7b49\u3002\u6b64\u66f4\u65b0\u4f7f\u5ea6\u91cf\u6807\u51c6\u53ef\u4ee5\u901a\u8fc7\u6784\u9020\u51fd\u6570\u53c2\u6570\u8fdb\u884c\u6709\u72b6\u6001\u548c\u53c2\u6570\u5316\u3002<\/p>\n

train_on_batch\u548ctest_on_batch\u65b9\u6cd5\u73b0\u5728\u6709\u4e00\u4e2a\u540d\u4e3aresent_metrics\u7684\u65b0\u53c2\u6570\u3002\u60a8\u53ef\u4ee5\u5c06\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3aTrue\uff0c\u4ee5\u4fbf\u5728\u7f16\u5199\u8f83\u4f4e\u7ea7\u522b\u7684\u57f9\u8bad\u6216\u8bc4\u4f30\u5faa\u73af\u65f6\u7ef4\u62a4\u4e0d\u540c\u6279\u6b21\u7684\u5ea6\u91cf\u6807\u51c6\u72b6\u6001\u3002<\/p>\n

model.reset_metrics()\u65b9\u6cd5\u88ab\u6dfb\u52a0\u5230Model\u4e2d\uff0c\u4ee5\u4fbf\u5728\u7f16\u5199\u8f83\u4f4e\u7ea7\u522b\u7684\u8bad\u7ec3\u6216\u8bc4\u4f30\u5faa\u73af\u65f6\u6e05\u9664\u7eaa\u5143\u5f00\u59cb\u65f6\u7684\u5ea6\u91cf\u6807\u51c6\u72b6\u6001\u3002<\/p>\n

<\/p>\n

Keras 2.3.0\u7684\u91cd\u5927\u53d8\u5316<\/strong><\/div>\n

<\/strong><\/p>\n

\u968f\u7740API\u7684\u53d8\u5316\uff0cKeras 2.3.0\u5305\u542b\u4e00\u4e9b\u91cd\u5927\u53d8\u5316\u3002\u5728\u6b64\u7248\u672c\u4e2d\uff0c\u4e0d\u63a8\u8350\u4f7f\u7528batch_size\uff0cwrite_grads\uff0cembeddings_freq\u548cembeddings_layer_names\uff0c\u56e0\u6b64\u5728\u4e0eTensorFlow 2.0\u4e00\u8d77\u4f7f\u7528\u65f6\u4f1a\u88ab\u5ffd\u7565\u3002\u73b0\u5728\u5c06\u6839\u636e\u7528\u6237\u6307\u5b9a\u7684\u786e\u5207\u540d\u79f0\u62a5\u544a\u6307\u6807\u548c\u635f\u5931\u3002\u6b64\u5916\uff0c\u9ed8\u8ba4\u7684\u91cd\u590d\u6fc0\u6d3b\u5728\u6240\u6709RNN\u5c42\u4e2d\u4ecehard_sigmoid\u66f4\u6539\u4e3asigmoid\u3002<\/p>\n

\u67e5\u770b\u5b98\u65b9\u516c\u544a<\/a>\uff0c\u4e86\u89e3Keras 2.3.0\u4e2d\u8fd8\u6709\u54ea\u4e9b\u6d88\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6b64\u7248\u672c\u9644\u5e26\u4e86\u8bb8\u591aAPI\u66f4\u6539\uff0c\u4ee5\u4f7f\u591a\u540e\u7aefKeras API\u4e0eTensorFlow\u7684\u9ad8\u7ea7API tf.keras\u201c […]<\/p>\n","protected":false},"author":63,"featured_media":158438,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-158437","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/158437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=158437"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/158437\/revisions"}],"predecessor-version":[{"id":159386,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/158437\/revisions\/159386"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/158438"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=158437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=158437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=158437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}