{"id":411,"date":"2017-09-19T17:51:21","date_gmt":"2017-09-19T08:51:21","guid":{"rendered":"http:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/?p=411"},"modified":"2017-09-20T10:24:48","modified_gmt":"2017-09-20T01:24:48","slug":"tensorflow%e3%81%a7mnist%e3%81%ae%e6%ac%a1%e3%81%ab%e5%ad%a6%e3%81%b6%e3%81%a8%e8%89%af%e3%81%95%e3%81%9d%e3%81%86%e3%81%aa%e3%81%93%e3%81%a8%e3%81%9d%e3%81%ae1","status":"publish","type":"post","link":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/?p=411","title":{"rendered":"Tensorflow\u3067MNIST\u306e\u6b21\u306b\u5b66\u3076\u3068\u826f\u3055\u305d\u3046\u306a\u3053\u3068(\u305d\u306e1)"},"content":{"rendered":"<h2>tensorflow\u3067\u904a\u3073\u306f\u3058\u3081\u307e\u3057\u305f<\/h2>\n<p>\u4e16\u9593\u3067\u6d41\u884c\u3063\u3066\u3044\u308b<code>tensorflow<\/code>\u3067\u904a\u3073\u59cb\u3081\u307e\u3057\u305f\u3002\u8a18\u9332\u304c\u3066\u3089\u306b\u904a\u3093\u3060\u3053\u3068\u3092\u307e\u3068\u3081\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u4e16\u306e\u4e2d\u306e\u8a18\u4e8b\u306f\u3069\u3046\u3082tensorflow\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300cMNIST\u3092\u3084\u3063\u3066\u307f\u305f\u300d\u3068\u304b\u3001\u300cCNN\u3092\u5b9f\u884c\u3057\u3066\u307f\u305f\u3002\u300d\u306a\u3069\u306e\u8a18\u4e8b\u304c\u591a\u3044\u5370\u8c61\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u4e00\u65b9\u3067\u300c\u624b\u66f8\u304d\u6587\u5b57\u3092\u8a8d\u8b58\u3059\u308b\u30a2\u30d7\u30ea\u3092\u4f5c\u308d\u3046\u300d\u3068\u3044\u3063\u305f\u5177\u4f53\u7684\u306b\u30a2\u30d7\u30ea\u3092\u4f5c\u308b\u3068\u5fc5\u8981\u306b\u306a\u3063\u3066\u304f\u308b\u60c5\u5831\u304c\u5c11\u306a\u3044\u5370\u8c61\u304c\u3042\u308b\u306e\u3067\u307e\u3068\u3081\u3066\u307f\u307e\u3059\u3002<\/p>\n<ul>\n<li>Tensorflow\u306e\u5b66\u7fd2\u306e\u3055\u305b\u304b\u305f(Estimator)<\/li>\n<li>Tensorflow\u306e\u5b66\u7fd2\u7d50\u679c\u306e\u5229\u7528\u65b9\u6cd5(SavedModel &amp; tensorflow serving)<\/li>\n<\/ul>\n<p>\u3092\u4e2d\u5fc3\u306b\u307e\u3068\u3081\u3066\u307f\u307e\u3059\u3002<\/p>\n<h2>\u81ea\u5206\u306e tensorflow \u3084 DeepLearning \u3068\u306e\u4ed8\u304d\u5408\u3044\u65b9<\/h2>\n<p>\u81ea\u5206\u306f\u6570\u5b66\u306e\u5929\u624d\u3067\u3082\u7121\u3044\u306e\u3067\u30cb\u30e5\u30fc\u30e9\u30eb\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3084\u6df1\u5c64\u5b66\u7fd2\u306e\u5c02\u9580\u5bb6\u3092\u76ee\u6307\u3059\u3064\u3082\u308a\u306f\u306a\u3044\u306e\u3067<\/p>\n<ul>\n<li>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306f\u8ab0\u304b(\u8ad6\u6587\u306a\u3069)\u3092\u53c2\u8003\u306b\u4f5c\u308b<\/li>\n<li>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u81ea\u5206\u3067\u3053\u306d\u304f\u308a\u56de\u3057\u305f\u308a\u306f\u3057\u306a\u3044<\/li>\n<li>\u5b66\u7fd2\u306f\u81ea\u524d\u306ePC\u3067\u5b9f\u65bd\u3057\u305f\u308a\u3059\u308b<\/li>\n<li>\u5b66\u7fd2\u7d50\u679c\u3092\u5229\u7528\u3057\u3066\u30a2\u30d7\u30ea\u306f\u516c\u958b\u3059\u308b(\u304b\u3082)<\/li>\n<\/ul>\n<p>\u304f\u3089\u3044\u306e\u7acb\u3061\u4f4d\u7f6e\u3067\u3059\u3002<\/p>\n<p>\u3042\u3068\u3001tensorflow\u3092\u4f7f\u3046\u306b\u3042\u305f\u3063\u3066\u6c7a\u307e\u308a\u306f\u7121\u3044\u306e\u3067\u3059\u304c\u3001contrib\u306e\u4e0b\u306b\u3042\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u6975\u529b\u4f7f\u308f\u306a\u3044\u65b9\u91dd\u3067\u3084\u3063\u3066\u307f\u3088\u3046\u3068\u8003\u3048\u3066\u3044\u307e\u3059\u3002<br \/>\ncontrib\u306e\u4e0b\u306b\u3042\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u3069\u3046\u3082\u7bc0\u64cd\u306a\u304f\u8272\u3005\u306a\u3082\u306e\u304c\u5165\u3063\u3066\u305d\u3046\u3067\u3001\u6d41\u884c\u308a\u5ec3\u308a\u3082\u901f\u305d\u3046\u306a\u306e\u3067\u8fd1\u5bc4\u308a\u305f\u304f\u306a\u3044\u306e\u3067\u3059\u2026\u2026\u3002<\/p>\n<h2>TensorFlow\u2019s high-level machine learning API (Estimator )<\/h2>\n<p>tensorflow\u306f\u4ee5\u524d\u306f\u3068\u3066\u3082\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u306aAPI\u3057\u304b\u63d0\u4f9b\u3057\u3066\u3044\u306a\u3044\u5370\u8c61\u304c\u3042\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u73fe\u5728\u306f\u5272\u3068\u9ad8\u6c34\u6e96\u306aAPI\u3082\u63d0\u4f9b\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<br \/>\n\u7279\u306bestimator\u306f\u3001tensorflow\u306esession\u306a\u3069\u3092\u96a0\u853d\u3057\u3066\u304f\u308c\u3066\u3001\u30e2\u30c7\u30eb\u306e\u69cb\u7bc9\u3001\u5b66\u7fd2\u3001\u8a55\u4fa1\u306e\u30d5\u30ed\u30fc\u3092\u96a0\u853d\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u5229\u7528\u3059\u308b\u3068\u8272\u3005\u697d\u3067\u3059\u3002<\/p>\n<p>\u4f7f\u3044\u65b9\u3068\u3057\u3066\u306f\u3001<a href=\"https:\/\/www.tensorflow.org\/extend\/estimators\">\u516c\u5f0f\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb<\/a>\u3092\u53c2\u8003\u306b\u3059\u308b\u306e\u304c\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u3053\u306e\u8a18\u4e8b\u306b\u66f8\u3044\u3066\u3042\u308b\u5185\u5bb9\u306f\u57fa\u672c\u7684\u306b\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u629c\u7c8b\u3067\u3059\u3002<\/p>\n<p>Tensorflow\u304c\u63d0\u4f9b\u3057\u3066\u304f\u308c\u3066\u3044\u308bEstimator\u3068\u3057\u3066\u306f\u4ee5\u4e0b\u306e\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>tf.estimator.LinearClassifier<\/li>\n<li>tf.estimator.LinearRegressor<\/li>\n<li>tf.estimator.DNNClassifier<\/li>\n<li>tf.estimator.DNNRegressor<\/li>\n<li>tf.estimator.DNNLinearCombinedClassifier<\/li>\n<li>tf.estimator.DNNRegressor<\/li>\n<\/ul>\n<p>\u3053\u308c\u3089\u3092\u5229\u7528\u3059\u308b\u5834\u5408\u306f\u3001\u305d\u308c\u305e\u308c\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u8aac\u660e\u3092\u898b\u308c\u3070\u4f7f\u3048\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>Estimator\u3092\u81ea\u4f5c\u3059\u308b<\/h2>\n<p>\u4e0a\u8a18\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u308f\u305a\u306b\u81ea\u524d\u3067\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u7d44\u3080\u5834\u5408(\u3053\u306e\u5834\u5408\u304c\u591a\u3044?)\u306f\u3001<code>Estimator<\/code>\u3092\u81ea\u5206\u3067\u4f5c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n<code>Estimator<\/code>\u306f<a href=\"https:\/\/www.tensorflow.org\/api_docs\/python\/tf\/estimator\/Estimator\">tf.estimator.Estimator<\/a> \u3067\u4f5c\u308a\u307e\u3059\u3002<br \/>\n\u5f15\u6570\u306e\u8a73\u7d30\u306f\u30de\u30cb\u30e5\u30a2\u30eb\u3092\u8aad\u3080\u306e\u304c\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u3068\u308a\u3042\u3048\u305a<code>model_fn<\/code>\u3068<code>params<\/code>\u3060\u3051\u77e5\u3063\u3066\u3044\u308c\u3070\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"python\">nn = tf.estimator.Estimator(model_fn=model_fn, params=model_params)\n# model_fn\u306f\u3001EstimatorSpec\u3092\u8fd4\u3059\u95a2\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\n# params\u306b\u306f\u5b66\u7fd2\u6642\u306e\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\n<\/code><\/pre>\n<h3>model_fn\u306e\u4f5c\u6210<\/h3>\n<p>\u3053\u3053\u3067\u3001model_fn\u306f\u5b9f\u969b\u3069\u3046\u3084\u3063\u3066\u4f5c\u308b\u306e\u304b\uff1f\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>model_fn\u306fmode\u3068feature\u3068params\u306e3\u3064\u3092\u5f15\u6570\u306b\u53d6\u3063\u3066\u3001\u305d\u308c\u3089\u306e\u60c5\u5831\u304b\u3089EstimatorSpec\u3092\u4f5c\u6210\u3057\u3066\u8fd4\u3059\u95a2\u6570\u3067\u3059\u3002<\/p>\n<p>\u5f15\u6570\u306f\u305d\u308c\u305e\u308c<\/p>\n<ul>\n<li>mode\u306f\u3053\u308c\u304b\u3089\u5b9f\u884c\u3059\u308b\u3082\u306e\u304c\u3001\u4e88\u6e2c\u306a\u306e\u304b\u5b66\u7fd2\u306a\u306e\u304b\u3092\u793a\u3059\u5024\u3067\u3059( tf.estimator.ModeKeys.PREDICT\u306a\u3069) <\/li>\n<li>feature\u306f\u540d\u524d\u306e\u901a\u308a\u5165\u529b\u30c7\u30fc\u30bf\u3067\u3059<\/li>\n<li>params\u306f<code>tf.estimator.Estimator<\/code>\u3067\u6e21\u3057\u305f\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u6e21\u3063\u3066\u6765\u307e\u3059<\/li>\n<\/ul>\n<p>\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n\u8fd4\u308a\u5024\u306eEstimatorSpec\u306e\u4f5c\u6210\u65b9\u6cd5\u3092\u6b21\u306f\u898b\u3066\u307f\u307e\u3059\u3002<\/p>\n<h4>EstimatorSpec\u306e\u4f5c\u6210\u65b9\u6cd5<\/h4>\n<p>EstimatorSpec\u306f\u3001<a href=\"https:\/\/www.tensorflow.org\/api_docs\/python\/tf\/estimator\/EstimatorSpec\">tf.estimator.EstimatorSpec<\/a> \u3067\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"python\">tf.estimator.EstimatorSpec(mode=mode,\n                                      predictions=predictions,\n                                      loss=loss,\n                                      train_op=train_op,\n                                      eval_metric_ops=eval_metric_ops,\n                                      export_outputs=export_outputs,\n                                      training_chief_hooks=None,\n                                      training_hooks=None,\n                                      scaffold=None)\n<\/code><\/pre>\n<p>\u3053\u306e\u95a2\u6570\u306e\u5f15\u6570\u3092\u305d\u308c\u305e\u308cmodel_fn\u5185\u3067\u8a2d\u5b9a\u3057\u3066\u3044\u304f\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u5177\u4f53\u7684\u306b\u306f\u3001<\/p>\n<ul>\n<li>train_op<\/li>\n<li>loss<\/li>\n<li>predictions<\/li>\n<\/ul>\n<p>\u306e\u4e09\u3064\u3092\u3068\u308a\u3042\u3048\u305a\u6307\u5b9a\u3057\u3066\u304a\u3051\u3070\u826f\u3044\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3068\u3057\u3066<\/p>\n<ul>\n<li>3\u5c64\u306e\u96a0\u308c\u5c64\u304b\u3089\u306a\u308b\u30cd\u30c3\u30c8\u30ef\u30fc\u30af<\/li>\n<li>crossentropy\u3092loss \u95a2\u6570<\/li>\n<li>\u6700\u9069\u5316\u624b\u6cd5\u306fGradientDescentOptimizer<\/li>\n<\/ul>\n<p>\u3068\u3044\u3046\u3082\u306e\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3059<\/p>\n<pre><code class=\"python\">def model_fn(features, labels, mode, params):\n    # \u3053\u3053\u3067\u6e21\u3063\u3066\u304f\u308bparams\u3068\u3044\u3046\u306e\u306fEstimator\u4f5c\u6210\u6642\u306e\u5f15\u6570\u306eparams\u3067\u3059\n\n    hidden1 = tf.layers.dense(inputs=feature['x'], units=10, activation=tf.nn.relu)\n    hidden2 = tf.layers.dense(inputs=hidden1,units=20, activation=tf.nn.relu)\n    hidden3 = tf.layers.dense(inputs=hidden2, units=10, activation=tf.nn.relu)\n    y = tf.layers.dense(inputs=hidden3, units=3, activation=tf.nn.softmax)\n\n    loss = None\n    train_op = None\n\n   # \u4e88\u6e2c\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408\u306fmode\u304ctf.estimator.ModeKeys.PREDICT\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u3002\n   # \u3053\u306e\u6642\u306f\u8a13\u7df4\u304c\u5b9f\u884c\u3055\u308c\u306a\u3044\u3088\u3046\u306b\u3057\u3066\u304a\u304d\u307e\u3059\u3002\n   # \u8981\u306f\u3001loss\u3068train_op\u306fNone\u306e\u307e\u307e\u3067\u3059\u3002\n    if mode != tf.estimator.ModeKeys.PREDICT:\n        y_ = tf.one_hot(labels, depth=3)\n        loss = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))\n        train_op = tf.train.GradientDescentOptimizer(0.01).minimize(loss, global_step=tf.train.get_global_step())\n\n    predictions = y\n\n    spec = tf.estimator.EstimatorSpec(mode=mode,\n                                      predictions=predictions,\n                                      loss=loss,\n                                      train_op=train_op)\n    return spec\n<\/code><\/pre>\n<h3>Estimator\u306e\u4f5c\u6210<\/h3>\n<p>\u3053\u3053\u307e\u3067\u3067\u3001Estimator\u3092\u4f5c\u6210\u3059\u308b\u6e96\u5099\u304c\u51fa\u6765\u305f\u306e\u3067Estimator\u3092\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002<br \/>\n\u4e0a\u306e\u95a2\u6570\u3067\u306f\u7279\u306b\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u6307\u5b9a\u304c\u7121\u3044(\u9177\u3044!)\u306e\u3067\u3001\u9069\u5f53\u306b\u6e21\u3057\u3066Estimator\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"python\">model_params = {}\nnn = tf.estimator.Estimator(model_fn=model_fn,  params=model_params)\n<\/code><\/pre>\n<p>\u7121\u4e8b<code>Estimator<\/code>\u3092\u4f5c\u308b\u3053\u3068\u304c\u51fa\u6765\u305f\u306f\u305a\u3067\u3059\u3002<br \/>\n\u305d\u308c\u3067\u306f\u3001\u3053\u306eEstimator\u3092\u4f7f\u3063\u3066\u5b66\u7fd2\u3001\u8a55\u4fa1\u3001\u4e88\u6e2c\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<h2>Estimator\u3092\u4f7f\u3063\u305f\u5b66\u7fd2\u3001\u8a55\u4fa1\u3001\u4e88\u6e2c<\/h2>\n<p>Estimator\u3092\u4f7f\u3063\u3066\u5b66\u7fd2\u3092\u3059\u308b\u5834\u5408\u306f\u3001\u4f5c\u6210\u3057\u305fEstimator\u306e<code>train<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3079\u3070\u81ea\u52d5\u7684\u306b\u5b66\u7fd2\u3057\u3066\u304f\u308c\u307e\u3059\u3002<br \/>\ntrain\u306e\u7b2c\u4e00\u5f15\u6570\u306f\u3001\u6559\u5e2b\u30c7\u30fc\u30bf\u3092\u8fd4\u3059\u3088\u3046\u306a\u95a2\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u95a2\u6570\u3067\u3059\u3002<\/p>\n<pre><code class=\"python\"># \u8a13\u7df4\u30c7\u30fc\u30bf\u3092\u8fd4\u3059\u95a2\u6570\ntrain_input_fn = tf.estimator.inputs.numpy_input_fn(\n    x={\"x\":  np.array(train_x, dtype='float32')} ,\n    y=np.array(train_y, dtype='int32'),\n    num_epochs=None,\n    shuffle=True)\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u95a2\u6570\u3092\u5165\u529b\u3068\u3057\u3066\u3001steps\u306f5000\u306b\u3057\u3066\u5b66\u7fd2\u3092\u884c\u306a\u3046\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"python\"># Train\nnn.train(input_fn=train_input_fn, steps=5000)\n<\/code><\/pre>\n<p>\u8a55\u4fa1\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408\u306f\u3001<code>evaluate<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3076\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u5f15\u6570\u3068\u3057\u3066\u306f\u3001<code>train<\/code>\u30e1\u30bd\u30c3\u30c9\u3068\u540c\u69d8\u306b\u5165\u529b\u30c7\u30fc\u30bf\u3092\u8fd4\u3059\u95a2\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"python\"># \u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u8fd4\u3059\u95a2\u6570\ntest_input_fn = tf.estimator.inputs.numpy_input_fn(\n    x={\"x\": np.array(test_x, dtype='float32')},\n    y=np.array(test_y, dtype='int32'),\n    num_epochs=1,\n    shuffle=False)\n\nev = nn.evaluate(input_fn=test_input_fn)\n\n# \u8a55\u4fa1\u7d50\u679c\u3092\u51fa\u529b\u3057\u3066\u307f\u308b\nfor key in sorted(ev):\n  print(\"%s: %s\" % (key, ev[key]))\n<\/code><\/pre>\n<p>\u4e88\u6e2c\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408\u306b\u306f\u3001<code>predict<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3079\u3070\u826f\u3044\u3067\u3059\u3002<br \/>\n\u5f15\u6570\u3068\u3057\u3066\u306f\u3001<code>train<\/code>\u30e1\u30bd\u30c3\u30c9\u3068\u540c\u69d8\u306b\u5165\u529b\u30c7\u30fc\u30bf\u3092\u8fd4\u3059\u95a2\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"python\"># Print out predictions\npredict_input_fn = tf.estimator.inputs.numpy_input_fn(\n    x={\"x\": np.array(test_x,dtype='float32')},\n    num_epochs=1,\n    shuffle=False)\npredictions = nn.predict(input_fn=predict_input_fn)\nfor i, j  in enumerate(predictions):\n    print(i, j)\n\n<\/code><\/pre>\n<h2>Estimator\u306e\u307e\u3068\u3081<\/h2>\n<ul>\n<li><code>Estimator<\/code>\u3068\u3044\u3046\u5b66\u7fd2\u3001\u8a55\u4fa1\u3001\u4e88\u6e2c\u3092\u307e\u3068\u3081\u3066\u304f\u308c\u308b\u4fbf\u5229\u306a\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u304c\u3042\u308a\u307e\u3059<\/li>\n<li><code>Estimator<\/code>\u3092\u4f5c\u6210\u3059\u308b\u306b\u306f\u3001<code>EstimatorSpec<\/code>\u3092\u8fd4\u3059model\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u307e\u3059\n<ul>\n<li>model\u95a2\u6570\u306b\u306f\u5b9f\u884c\u30e2\u30fc\u30c9\u3068\u30c7\u30fc\u30bf\u3068\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u6e21\u3063\u3066\u304d\u307e\u3059<\/li>\n<li>model\u95a2\u6570\u306fmode\u3068\u4e88\u6e2c\u7d50\u679c\u3001\u8aa4\u5dee\u95a2\u6570\u3001\u6700\u9069\u5316\u624b\u6cd5\u3092\u5b9a\u7fa9\u3057\u3001\u3053\u308c\u3089\u306e\u60c5\u5831\u304b\u3089EstimatorSpec\u3092\u4f5c\u6210\u3057\u307e\u3059<\/li>\n<\/ul>\n<\/li>\n<li><code>Estimator<\/code>\u3092\u4f5c\u6210\u3059\u308c\u3070\u3001train, evaluate, predict\u306e\u95a2\u6570\u3067\u5b66\u7fd2\u3001\u8a55\u4fa1\u3001\u4e88\u6e2c\u304c\u5b9f\u884c\u3067\u304d\u307e\u3059\n<ul>\n<li>\u305d\u308c\u305e\u308c\u306e\u30e1\u30bd\u30c3\u30c9\u306b\u306f\u3001\u5165\u529b\u3092\u4e0e\u3048\u308b\u95a2\u6570\u3092\u5b9a\u7fa9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059<\/li>\n<li><code>tf.estimator.inputs.numpy_input_fn<\/code>\u306a\u3069\u3092\u5229\u7528\u3059\u308c\u3070\u624b\u8efd\u306b\u5b9f\u88c5\u3067\u304d\u307e\u3059<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>savedmodel\u306b\u3064\u3044\u3066<\/h2>\n<p>\u66f8\u304f\u306e\u306b\u75b2\u308c\u305f\u306e\u3067\u3001\u660e\u65e5\u4ee5\u964d\u306b\u5225\u8a18\u4e8b\u306b\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>tensorflow\u3067\u904a\u3073\u306f\u3058\u3081\u307e\u3057\u305f \u4e16\u9593\u3067\u6d41\u884c\u3063\u3066\u3044\u308btensorflow\u3067\u904a\u3073\u59cb\u3081\u307e\u3057\u305f\u3002\u8a18\u9332\u304c\u3066\u3089\u306b\u904a\u3093\u3060\u3053\u3068\u3092\u307e\u3068\u3081\u3066\u307f\u307e\u3059\u3002 \u4e16\u306e\u4e2d\u306e\u8a18\u4e8b\u306f\u3069\u3046\u3082tensorflow\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300cMNIST\u3092\u3084\u3063\u3066\u307f\u305f\u2026 <span class=\"read-more\"><a href=\"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/?p=411\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4,3,2],"tags":[],"class_list":["post-411","post","type-post","status-publish","format-standard","hentry","category-deeplearning","category-python","category-tensorflow"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4wwqG-6D","_links":{"self":[{"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=\/wp\/v2\/posts\/411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=411"}],"version-history":[{"count":40,"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=\/wp\/v2\/posts\/411\/revisions"}],"predecessor-version":[{"id":453,"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=\/wp\/v2\/posts\/411\/revisions\/453"}],"wp:attachment":[{"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/light-of-moe.ddo.jp\/~sakura\/diary\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}