Skip to content

Commit 48bbec7

Browse files
MarkDaoustcopybara-github
authored andcommitted
Remove assert
PiperOrigin-RevId: 484086748
1 parent 93eeb83 commit 48bbec7

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

site/en/tutorials/images/classification.ipynb

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,16 +1110,43 @@
11101110
"outputs": [],
11111111
"source": [
11121112
"predictions_lite = classify_lite(sequential_1_input=img_array)['outputs']\n",
1113-
"score_lite = tf.nn.softmax(predictions_lite)\n",
1114-
"\n",
1115-
"assert np.allclose(predictions, predictions_lite)\n",
1116-
"\n",
1113+
"score_lite = tf.nn.softmax(predictions_lite)"
1114+
]
1115+
},
1116+
{
1117+
"cell_type": "code",
1118+
"execution_count": null,
1119+
"metadata": {
1120+
"id": "ZKP_GFeKUWb5"
1121+
},
1122+
"outputs": [],
1123+
"source": [
11171124
"print(\n",
11181125
" \"This image most likely belongs to {} with a {:.2f} percent confidence.\"\n",
11191126
" .format(class_names[np.argmax(score_lite)], 100 * np.max(score_lite))\n",
11201127
")"
11211128
]
11221129
},
1130+
{
1131+
"cell_type": "markdown",
1132+
"metadata": {
1133+
"id": "Poz_iYgeUg_U"
1134+
},
1135+
"source": [
1136+
"The prediction generated by the lite model should be almost identical to the predictions generated by the original model:"
1137+
]
1138+
},
1139+
{
1140+
"cell_type": "code",
1141+
"execution_count": null,
1142+
"metadata": {
1143+
"id": "InXXDJL8UYC1"
1144+
},
1145+
"outputs": [],
1146+
"source": [
1147+
"print(np.max(np.abs(predictions - predictions_lite)))"
1148+
]
1149+
},
11231150
{
11241151
"cell_type": "markdown",
11251152
"metadata": {
@@ -1148,6 +1175,7 @@
11481175
"colab": {
11491176
"collapsed_sections": [],
11501177
"name": "classification.ipynb",
1178+
"provenance": [],
11511179
"toc_visible": true
11521180
},
11531181
"kernelspec": {

0 commit comments

Comments
 (0)