From ddca55b10be8146772160f5e2cc70c452d8b5c0b Mon Sep 17 00:00:00 2001 From: Abhijeet Singh Date: Mon, 16 Jul 2018 00:33:30 +0530 Subject: [PATCH 1/5] Fix for issue #4 --- ep7.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ep7.ipynb b/ep7.ipynb index a54bc04..0e7b351 100644 --- a/ep7.ipynb +++ b/ep7.ipynb @@ -294,7 +294,8 @@ ], "source": [ "# here's one it gets right\n", - "print (\"Predicted %d, Label: %d\" % (classifier.predict(test_data[0]), test_labels[0]))\n", + "prediction = classifier.predict(np.array([test_data[0]], dtype=float), as_iterable=False)", + "print (\"Predicted %d, Label: %d\" % (prediction, test_labels[0]))\n", "display(0)" ] }, From 693f6eba3cd3c8aa959d4b41118fd17d488cc224 Mon Sep 17 00:00:00 2001 From: Abhijeet Singh Date: Mon, 16 Jul 2018 01:10:15 +0530 Subject: [PATCH 2/5] Fixed both occurrences of issue #4 --- ep7.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ep7.ipynb b/ep7.ipynb index 0e7b351..7f493cd 100644 --- a/ep7.ipynb +++ b/ep7.ipynb @@ -326,7 +326,8 @@ ], "source": [ "# and one it gets wrong\n", - "print (\"Predicted %d, Label: %d\" % (classifier.predict(test_data[8]), test_labels[8]))\n", + "prediction = classifier.predict(np.array([test_data[0]], dtype=float), as_iterable=False)", + "print (\"Predicted %d, Label: %d\" % (prediction, test_labels[8]))\n", "display(8)" ] }, From 8b283e3ab0915b8d54ebf94280df1ee7c92a2388 Mon Sep 17 00:00:00 2001 From: Abhijeet Singh Date: Mon, 16 Jul 2018 01:32:15 +0530 Subject: [PATCH 3/5] Added newline for text wrapping issue after issue #4 fix --- ep7.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ep7.ipynb b/ep7.ipynb index 7f493cd..0a0f3c3 100644 --- a/ep7.ipynb +++ b/ep7.ipynb @@ -294,7 +294,7 @@ ], "source": [ "# here's one it gets right\n", - "prediction = classifier.predict(np.array([test_data[0]], dtype=float), as_iterable=False)", + "prediction = classifier.predict(np.array([test_data[0]], dtype=float), as_iterable=False)\n", "print (\"Predicted %d, Label: %d\" % (prediction, test_labels[0]))\n", "display(0)" ] @@ -326,7 +326,7 @@ ], "source": [ "# and one it gets wrong\n", - "prediction = classifier.predict(np.array([test_data[0]], dtype=float), as_iterable=False)", + "prediction = classifier.predict(np.array([test_data[0]], dtype=float), as_iterable=False)\n", "print (\"Predicted %d, Label: %d\" % (prediction, test_labels[8]))\n", "display(8)" ] From 83ff851813dc6e804b41d6869ccc8526eb3a2a0f Mon Sep 17 00:00:00 2001 From: Abhijeet Singh Date: Mon, 16 Jul 2018 12:49:44 +0530 Subject: [PATCH 4/5] Fix for issue #5 Added fix for the following error on newer TensorFlow versions: AttributeError: 'LinearClassifier' object has no attribute 'weights_' Tested on Python 3.5.2 and TensorFlow 1.9.0 --- ep7.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ep7.ipynb b/ep7.ipynb index 0a0f3c3..7b070cb 100644 --- a/ep7.ipynb +++ b/ep7.ipynb @@ -360,7 +360,7 @@ } ], "source": [ - "weights = classifier.weights_\n", + "weights = classifier.get_variable_value("linear//weight")\n", "f, axes = plt.subplots(2, 5, figsize=(10,4))\n", "axes = axes.reshape(-1)\n", "for i in range(len(axes)):\n", From abbe5573ca828d79b588693a8f43eb464ce226e5 Mon Sep 17 00:00:00 2001 From: Abhijeet Singh Date: Mon, 16 Jul 2018 13:02:47 +0530 Subject: [PATCH 5/5] Fixed escape characters for Notebook --- ep7.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ep7.ipynb b/ep7.ipynb index 7b070cb..1839c13 100644 --- a/ep7.ipynb +++ b/ep7.ipynb @@ -360,7 +360,7 @@ } ], "source": [ - "weights = classifier.get_variable_value("linear//weight")\n", + "weights = classifier.get_variable_value(\"linear//weight\")\n", "f, axes = plt.subplots(2, 5, figsize=(10,4))\n", "axes = axes.reshape(-1)\n", "for i in range(len(axes)):\n",