Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
8cbdb869
Commit
8cbdb869
authored
Aug 16, 2018
by
Mark Daoust
Browse files
minor cleanup
parent
fbe06895
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
154 deletions
+62
-154
samples/core/tutorials/keras/basic_classification.ipynb
samples/core/tutorials/keras/basic_classification.ipynb
+62
-154
No files found.
samples/core/tutorials/keras/basic_classification.ipynb
View file @
8cbdb869
...
...
@@ -5,8 +5,6 @@
"colab": {
"name": "basic_classification.ipynb",
"version": "0.3.2",
"views": {},
"default_view": {},
"provenance": [],
"private_outputs": true,
"collapsed_sections": [],
...
...
@@ -32,12 +30,7 @@
"metadata": {
"id": "_ckMIh7O7s6D",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
},
"colab": {},
"cellView": "form"
},
"cell_type": "code",
...
...
@@ -61,12 +54,7 @@
"metadata": {
"id": "vasWnqRgy1H4",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
},
"colab": {},
"cellView": "form"
},
"cell_type": "code",
...
...
@@ -142,12 +130,7 @@
"metadata": {
"id": "dzLKpmZICaWN",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -204,12 +187,7 @@
"metadata": {
"id": "7MqDQO0KCaWS",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -288,12 +266,7 @@
"metadata": {
"id": "IjnLH5S2CaWx",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -319,12 +292,7 @@
"metadata": {
"id": "zW5k_xz1CaWX",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -347,12 +315,7 @@
"metadata": {
"id": "TRFYHB2mCaWb",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -375,12 +338,7 @@
"metadata": {
"id": "XKnCTHz4CaWg",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -403,12 +361,7 @@
"metadata": {
"id": "2KFnYlcwCaWl",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -431,12 +384,7 @@
"metadata": {
"id": "iJmPr5-ACaWn",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -461,19 +409,14 @@
"metadata": {
"id": "m4VEw8Ud9Quh",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
"plt.figure()\n",
"plt.imshow(train_images[0])\n",
"plt.colorbar()\n",
"plt.g
ca().grid(False
)"
"plt.g
rid('off'
)"
],
"execution_count": 0,
"outputs": []
...
...
@@ -502,12 +445,7 @@
"metadata": {
"id": "bW5WzIPlCaWv",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -532,12 +470,7 @@
"metadata": {
"id": "oZTImqg_CaW1",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -583,12 +516,7 @@
"metadata": {
"id": "9ODch-OFCaW4",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -625,12 +553,7 @@
"metadata": {
"id": "Lhan11blCaW7",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -663,12 +586,7 @@
"metadata": {
"id": "xvwvpA64CaW_",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -703,12 +621,7 @@
"metadata": {
"id": "VflXLEeECaXC",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -745,12 +658,7 @@
"metadata": {
"id": "Gl91RPhdCaXI",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -773,12 +681,7 @@
"metadata": {
"id": "3DmJEUinCaXK",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -801,12 +704,7 @@
"metadata": {
"id": "qsqenuPnCaXO",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -829,12 +727,7 @@
"metadata": {
"id": "Sd7Pgsu6CaXP",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
"colab": {}
},
"cell_type": "code",
"source": [
...
...
@@ -861,10 +754,12 @@
},
"cell_type": "code",
"source": [
"def plot_image(predictions_array, true_label, img):\n",
"def plot_image(i, predictions_array, true_label, img):\n",
" predictions_array, true_label, img = predictions_array[i], true_label[i], img[i]\n",
" plt.grid('off')\n",
" plt.xticks([])\n",
" plt.yticks([])\n",
"
plt.grid('off')
\n",
" \n",
" plt.imshow(img, cmap=plt.cm.binary)\n",
"\n",
" predicted_label = np.argmax(predictions_array)\n",
...
...
@@ -872,12 +767,14 @@
" color = 'blue'\n",
" else:\n",
" color = 'red'\n",
" plt.xlabel(\"{} {} ({})\".format(class_names[predicted_label],\n",
" str(round(predictions_array[np.argmax(predictions_array)] * 100)) + \"%\",\n",
" \n",
" plt.xlabel(\"{} {:2.0f}% ({})\".format(class_names[predicted_label],\n",
" 100*np.max(predictions_array),\n",
" class_names[true_label]),\n",
" color=color)\n",
"\n",
"def plot_value_array(predictions_array, true_label):\n",
"def plot_value_array(i, predictions_array, true_label):\n",
" predictions_array, true_label = predictions_array[i], true_label[i]\n",
" plt.grid('off')\n",
" plt.xticks([])\n",
" plt.yticks([])\n",
...
...
@@ -886,20 +783,7 @@
" predicted_label = np.argmax(predictions_array)\n",
" \n",
" thisplot[predicted_label].set_color('red')\n",
" thisplot[true_label].set_color('blue')\n",
"\n",
" \n",
"# define plot to look at the image, predicted label, actual label, predicted percent for top prediction, and graph of all prediction values\n",
"def plot_fig_and_predarray(iter):\n",
" plt.figure(figsize=(6,3))\n",
" \n",
" # plot the image first\n",
" plt.subplot(1,2,1)\n",
" plot_image(predictions[iter], test_labels[iter], test_images[int(iter)])\n",
" \n",
" # then the graph of 10 values\n",
" plt.subplot(1,2,2)\n",
" plot_value_array(predictions[iter], test_labels[iter])"
" thisplot[true_label].set_color('blue')"
],
"execution_count": 0,
"outputs": []
...
...
@@ -922,7 +806,12 @@
},
"cell_type": "code",
"source": [
"plot_fig_and_predarray(0)"
"i = 0\n",
"plt.figure(figsize=(6,3))\n",
"plt.subplot(1,2,1)\n",
"plot_image(i, predictions, test_labels, test_images)\n",
"plt.subplot(1,2,2)\n",
"plot_value_array(i, predictions, test_labels)"
],
"execution_count": 0,
"outputs": []
...
...
@@ -935,7 +824,12 @@
},
"cell_type": "code",
"source": [
"plot_fig_and_predarray(12)"
"i = 12\n",
"plt.figure(figsize=(6,3))\n",
"plt.subplot(1,2,1)\n",
"plot_image(i, predictions, test_labels, test_images)\n",
"plt.subplot(1,2,2)\n",
"plot_value_array(i, predictions, test_labels)"
],
"execution_count": 0,
"outputs": []
...
...
@@ -966,9 +860,9 @@
"plt.figure(figsize=(2*2*num_cols, 2*num_rows))\n",
"for i in range(num_images):\n",
" plt.subplot(num_rows, 2*num_cols, 2*i+1)\n",
" plot_image(predictions
[i]
, test_labels
[i]
, test_images
[i]
)\n",
" plot_image(
i,
predictions, test_labels, test_images)\n",
" plt.subplot(num_rows, 2*num_cols, 2*i+2)\n",
" plot_value_array(predictions
[i]
, test_labels
[i]
)\n"
" plot_value_array(
i,
predictions, test_labels)\n"
],
"execution_count": 0,
"outputs": []
...
...
@@ -1050,6 +944,20 @@
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "6Ai-cpLjO-3A",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"plot_value_array(0, predictions_single, test_labels)\n",
"_ = plt.xticks(range(10), class_names, rotation=45)"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "cU1Y2OAMCaXb",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment