Skip to content

Instantly share code, notes, and snippets.

@ritog
Created November 20, 2020 18:26
Show Gist options
  • Save ritog/9ef1eace15ce2e62a646402573b58e32 to your computer and use it in GitHub Desktop.
Save ritog/9ef1eace15ce2e62a646402573b58e32 to your computer and use it in GitHub Desktop.
Fashion_MNIST_Training.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
},
"colab": {
"name": "Fashion_MNIST_Training.ipynb",
"provenance": [],
"include_colab_link": true
},
"accelerator": "GPU",
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"c18a37d6a7074ea19bb19b8ff1415da9": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_896c96146c2c4613abca96c05077df32",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_7b311b288fdd490d98fadee2a2f55b06",
"IPY_MODEL_8f9d58c7d39e4b8faba78b722617a8c1"
]
}
},
"896c96146c2c4613abca96c05077df32": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"7b311b288fdd490d98fadee2a2f55b06": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_c05b401fc0e342e9a5ed268c77dc534b",
"_dom_classes": [],
"description": "",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 1,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 1,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_7041c97a45d44afebc389e4b2f25becd"
}
},
"8f9d58c7d39e4b8faba78b722617a8c1": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_36b4a4e237b54646a5f0c39e66952ad7",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 26427392/? [00:03<00:00, 7003838.68it/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_d1701a4698d44d58b7b49253146775f3"
}
},
"c05b401fc0e342e9a5ed268c77dc534b": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"7041c97a45d44afebc389e4b2f25becd": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"36b4a4e237b54646a5f0c39e66952ad7": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"d1701a4698d44d58b7b49253146775f3": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"03acfc9243c84bbc942bd40e948f01b0": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_cb96f541dfd048b7afce6c762950c461",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_06e7caf67457495684604c04d6b0983d",
"IPY_MODEL_5b7d0540bfc3493fac3a6c676080b088"
]
}
},
"cb96f541dfd048b7afce6c762950c461": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"06e7caf67457495684604c04d6b0983d": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_666a8b59b68a4e3a8ade6d268a11650f",
"_dom_classes": [],
"description": "",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 1,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 1,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_f44405a8e8504db0a13d9eea2d6fdc0b"
}
},
"5b7d0540bfc3493fac3a6c676080b088": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_38473c19f77842d08bf68b8f139e7187",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 32768/? [00:00<00:00, 99900.75it/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_4cc0ba72f73146e3aa0c84a981cdea98"
}
},
"666a8b59b68a4e3a8ade6d268a11650f": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"f44405a8e8504db0a13d9eea2d6fdc0b": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"38473c19f77842d08bf68b8f139e7187": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"4cc0ba72f73146e3aa0c84a981cdea98": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"a45704b2a772424eaf96869dc2fc5470": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_c64491cdc8054861946539ee9d0d6d81",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_1ce4737d61894be48589800dc07f0d53",
"IPY_MODEL_e875ae7e3ba844868e6c7ed235982fca"
]
}
},
"c64491cdc8054861946539ee9d0d6d81": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"1ce4737d61894be48589800dc07f0d53": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_b53831a315ff4670a26afebf307cb774",
"_dom_classes": [],
"description": "",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 1,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 1,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_475cfbfe8ca440c5958e0552dab057b6"
}
},
"e875ae7e3ba844868e6c7ed235982fca": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_999ce33525e44ff0a35945f6951aee0b",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 4423680/? [00:01<00:00, 3124285.83it/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_19c153b2c9524f019bb00b87eab6160b"
}
},
"b53831a315ff4670a26afebf307cb774": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"475cfbfe8ca440c5958e0552dab057b6": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"999ce33525e44ff0a35945f6951aee0b": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"19c153b2c9524f019bb00b87eab6160b": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"46b7868342e54857bf59d01774882177": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_1c5fc2b6fad6427caffc8b8c526557c8",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_aff34f24657540d4a8281101dfd539f6",
"IPY_MODEL_63d80527cf44430a87083308553188f4"
]
}
},
"1c5fc2b6fad6427caffc8b8c526557c8": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"aff34f24657540d4a8281101dfd539f6": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_d8ce7aada0514a9baafbd15170d6a39e",
"_dom_classes": [],
"description": "",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 1,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 1,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_7ba2de6782004f6ca7e64443f6b210aa"
}
},
"63d80527cf44430a87083308553188f4": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_40e445b4b17a4ba99568da4bae33b4a6",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 8192/? [00:00<00:00, 20581.77it/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_baa596aa1c454bbcacb698cb8098862f"
}
},
"d8ce7aada0514a9baafbd15170d6a39e": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"7ba2de6782004f6ca7e64443f6b210aa": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"40e445b4b17a4ba99568da4bae33b4a6": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"baa596aa1c454bbcacb698cb8098862f": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
}
}
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/ghosh-r/9ef1eace15ce2e62a646402573b58e32/fashion_mnist_training.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ho3C5Z9eDRnn"
},
"source": [
"# Classifying Fashion-MNIST\n",
"\n",
"[Fashion-MNIST dataset](https://github.com/zalandoresearch/fashion-mnist) is a set of 28x28 greyscale images of clothes.\n",
"\n",
"<img src='https://github.com/udacity/deep-learning-v2-pytorch/blob/master/intro-to-pytorch/assets/fashion-mnist-sprite.png?raw=1' width=500px>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "BcW-YeegDRno",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 437,
"referenced_widgets": [
"c18a37d6a7074ea19bb19b8ff1415da9",
"896c96146c2c4613abca96c05077df32",
"7b311b288fdd490d98fadee2a2f55b06",
"8f9d58c7d39e4b8faba78b722617a8c1",
"c05b401fc0e342e9a5ed268c77dc534b",
"7041c97a45d44afebc389e4b2f25becd",
"36b4a4e237b54646a5f0c39e66952ad7",
"d1701a4698d44d58b7b49253146775f3",
"03acfc9243c84bbc942bd40e948f01b0",
"cb96f541dfd048b7afce6c762950c461",
"06e7caf67457495684604c04d6b0983d",
"5b7d0540bfc3493fac3a6c676080b088",
"666a8b59b68a4e3a8ade6d268a11650f",
"f44405a8e8504db0a13d9eea2d6fdc0b",
"38473c19f77842d08bf68b8f139e7187",
"4cc0ba72f73146e3aa0c84a981cdea98",
"a45704b2a772424eaf96869dc2fc5470",
"c64491cdc8054861946539ee9d0d6d81",
"1ce4737d61894be48589800dc07f0d53",
"e875ae7e3ba844868e6c7ed235982fca",
"b53831a315ff4670a26afebf307cb774",
"475cfbfe8ca440c5958e0552dab057b6",
"999ce33525e44ff0a35945f6951aee0b",
"19c153b2c9524f019bb00b87eab6160b",
"46b7868342e54857bf59d01774882177",
"1c5fc2b6fad6427caffc8b8c526557c8",
"aff34f24657540d4a8281101dfd539f6",
"63d80527cf44430a87083308553188f4",
"d8ce7aada0514a9baafbd15170d6a39e",
"7ba2de6782004f6ca7e64443f6b210aa",
"40e445b4b17a4ba99568da4bae33b4a6",
"baa596aa1c454bbcacb698cb8098862f"
]
},
"outputId": "b8ae8a28-f2e8-417b-9f95-f3b85c0859d8"
},
"source": [
"import torch\n",
"from torchvision import datasets, transforms\n",
"\n",
"transform = transforms.Compose([transforms.ToTensor(),\n",
" transforms.Normalize((0.5,), (0.5,))])\n",
"\n",
"trainset = datasets.FashionMNIST('~/.pytorch/F_MNIST_data/', download=True, train=True, transform=transform)\n",
"trainloader = torch.utils.data.DataLoader(trainset, batch_size=64, shuffle=True)\n",
"\n",
"testset = datasets.FashionMNIST('~/.pytorch/F_MNIST_data/', download=True, train=False, transform=transform)\n",
"testloader = torch.utils.data.DataLoader(testset, batch_size=64, shuffle=True)"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": [
"Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-images-idx3-ubyte.gz to /root/.pytorch/F_MNIST_data/FashionMNIST/raw/train-images-idx3-ubyte.gz\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c18a37d6a7074ea19bb19b8ff1415da9",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Extracting /root/.pytorch/F_MNIST_data/FashionMNIST/raw/train-images-idx3-ubyte.gz to /root/.pytorch/F_MNIST_data/FashionMNIST/raw\n",
"Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-labels-idx1-ubyte.gz to /root/.pytorch/F_MNIST_data/FashionMNIST/raw/train-labels-idx1-ubyte.gz\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "03acfc9243c84bbc942bd40e948f01b0",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Extracting /root/.pytorch/F_MNIST_data/FashionMNIST/raw/train-labels-idx1-ubyte.gz to /root/.pytorch/F_MNIST_data/FashionMNIST/raw\n",
"Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-images-idx3-ubyte.gz to /root/.pytorch/F_MNIST_data/FashionMNIST/raw/t10k-images-idx3-ubyte.gz\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a45704b2a772424eaf96869dc2fc5470",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Extracting /root/.pytorch/F_MNIST_data/FashionMNIST/raw/t10k-images-idx3-ubyte.gz to /root/.pytorch/F_MNIST_data/FashionMNIST/raw\n",
"Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-labels-idx1-ubyte.gz to /root/.pytorch/F_MNIST_data/FashionMNIST/raw/t10k-labels-idx1-ubyte.gz\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "46b7868342e54857bf59d01774882177",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Extracting /root/.pytorch/F_MNIST_data/FashionMNIST/raw/t10k-labels-idx1-ubyte.gz to /root/.pytorch/F_MNIST_data/FashionMNIST/raw\n",
"Processing...\n",
"Done!\n",
"\n",
"\n",
"\n"
],
"name": "stdout"
},
{
"output_type": "stream",
"text": [
"/usr/local/lib/python3.6/dist-packages/torchvision/datasets/mnist.py:480: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at /pytorch/torch/csrc/utils/tensor_numpy.cpp:141.)\n",
" return torch.from_numpy(parsed.astype(m[2], copy=False)).view(*s)\n"
],
"name": "stderr"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "QK5OMe3-v8ve",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "667412ac-ee26-43a4-c1d4-75aebfffd93f"
},
"source": [
"device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n",
"device"
],
"execution_count": 2,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"device(type='cuda')"
]
},
"metadata": {
"tags": []
},
"execution_count": 2
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Yb7mADELDRno"
},
"source": [
"Here we can see one of the images."
]
},
{
"cell_type": "code",
"metadata": {
"id": "fad8F7gyKxHA"
},
"source": [
"import matplotlib.pyplot as plt"
],
"execution_count": 3,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "ll0t3B0RDRno",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 265
},
"outputId": "d6a27ffd-dc1a-42f6-afc3-303983103f24"
},
"source": [
"image, label = next(iter(trainloader))\n",
"plt.imshow(image[0,0,:], cmap='Greys');"
],
"execution_count": 4,
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAASX0lEQVR4nO3dbWxVZbYH8P8CyktaXlopBQGBC2okvgApiA6O6DhE8AMQEzOYTLgoYqImjJmYa7gfMMEPaJwhfLgS4IqAGR0nmSFC1HunECIhKngkXEHkKpeUtxRaKJYiUCys+6EbU6B7PeXss885dP1/CWl71nnOeTj0z2n32vt5RFVBRF1ft0JPgIjyg2EncoJhJ3KCYSdygmEncqJHPp9s4MCBOnLkyHw+ZV60tLSY9YaGBrPeq1cvs15RUWHWu3fvbtZvVk1NTWb9/PnzZn3QoEGxtW7duub7XG1tLU6ePCkd1RKFXUQeB7AcQHcA/6mqS637jxw5EplMJslTFqWDBw+a9ZUrV5r1ESNGmPWnn37arA8YMMCs36w2bdp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qjoBwHQAL0Y/rhYlbfsdrJh6p53axjtfOthm/BeFfO2y3f48qUKE/RiA4e2+HhbdVhRU9Vj0sR7ABhTfVtQnruygG32sL/B8flFM23h3tM04iuC1K+T254UI+1cAbheRUSLSE8DvAGwswDyuIyKl0YETiEgpgGkovq2oNwKYG30+F8BHBZzLVYplG++4bcZR4Neu4Nufq2re/wCYgbYj8v8H4N8LMYeYef0LgP+J/nxb6LkB+ABtP9b9jLZjG88CuAXAFgA/ANgMoKKI5vYegD0AvkFbsIYUaG5T0PYj+jcAdkd/ZhT6tTPmlZfXjafLEjnBA3RETjDsRE4w7EROMOxETjDsRE4w7EROMOxETvw/rKoS1l9LE9wAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"tags": [],
"needs_background": "light"
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Td9YYudLjElH",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "0126aa4d-68bf-4c56-9857-38eb0756a988"
},
"source": [
"image.shape, label.shape"
],
"execution_count": 5,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"(torch.Size([64, 1, 28, 28]), torch.Size([64]))"
]
},
"metadata": {
"tags": []
},
"execution_count": 5
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "SK350OzjDRno"
},
"source": [
"## Building the network"
]
},
{
"cell_type": "code",
"metadata": {
"id": "UN-S9paZvmFc"
},
"source": [
"from torch import nn\n",
"import torch.nn.functional as F"
],
"execution_count": 6,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "mKKr0Un6DRno"
},
"source": [
"class Network(nn.Module):\n",
" def __init__(self):\n",
" super(Network, self).__init__()\n",
"\n",
" self.fc1 = nn.Linear(28*28, 256)\n",
" self.fc2 = nn.Linear(256, 256)\n",
" self.fc3 = nn.Linear(256, 64)\n",
" self.fc4 = nn.Linear(64, 64)\n",
" self.fc5 = nn.Linear(64, 10)\n",
"\n",
" def forward(self, x):\n",
" x = F.relu(self.fc1(x))\n",
" x = F.relu(self.fc2(x))\n",
" x = F.relu(self.fc3(x))\n",
" x = F.relu(self.fc4(x))\n",
" x = F.softmax(self.fc5(x), dim=1)\n",
"\n",
" return x"
],
"execution_count": 7,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "IIdo1Gw0JP-3",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "26a3310b-74ba-4c50-e1dd-0eba18a2b966"
},
"source": [
"model = Network()\n",
"model.to(device)\n",
"model"
],
"execution_count": 8,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"Network(\n",
" (fc1): Linear(in_features=784, out_features=256, bias=True)\n",
" (fc2): Linear(in_features=256, out_features=256, bias=True)\n",
" (fc3): Linear(in_features=256, out_features=64, bias=True)\n",
" (fc4): Linear(in_features=64, out_features=64, bias=True)\n",
" (fc5): Linear(in_features=64, out_features=10, bias=True)\n",
")"
]
},
"metadata": {
"tags": []
},
"execution_count": 8
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "-5PRVVHJDRno"
},
"source": [
"\n",
"# Training the network"
]
},
{
"cell_type": "code",
"metadata": {
"id": "f4KpTj6rOwUS"
},
"source": [
"from torch import optim"
],
"execution_count": 9,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "32U4RAjKDRno"
},
"source": [
"criterion = nn.CrossEntropyLoss()\n",
"optimizer = optim.SGD(model.parameters(), lr=0.009)"
],
"execution_count": 10,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "JLc2gljsDRnp",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "2369443e-dc33-4fe9-a2f7-562ad38d5fb9"
},
"source": [
"for epoch in range(25):\n",
" running_loss = 0\n",
" for image, label in trainloader:\n",
" image, label = image.to(device), label.to(device)\n",
" image = image.view(image.shape[0], -1)\n",
"\n",
" optimizer.zero_grad()\n",
"\n",
" output = model(image)\n",
" loss = criterion(output, label)\n",
" loss.backward()\n",
"\n",
" optimizer.step()\n",
"\n",
" running_loss += loss.item()\n",
"\n",
" else:\n",
" print(f\"Training loss: {running_loss/len(trainloader)}\")"
],
"execution_count": 11,
"outputs": [
{
"output_type": "stream",
"text": [
"Training loss: 2.30225410288585\n",
"Training loss: 2.3014346264572794\n",
"Training loss: 2.300310645276295\n",
"Training loss: 2.2982762065777647\n",
"Training loss: 2.293135287919278\n",
"Training loss: 2.2587068868852627\n",
"Training loss: 2.170536396600036\n",
"Training loss: 2.068142019736487\n",
"Training loss: 1.929231432963536\n",
"Training loss: 1.8503042384505526\n",
"Training loss: 1.8161777144810285\n",
"Training loss: 1.7979587796908707\n",
"Training loss: 1.7853560234183696\n",
"Training loss: 1.7752022881751883\n",
"Training loss: 1.7654367168066598\n",
"Training loss: 1.7565805426538625\n",
"Training loss: 1.7503288355209172\n",
"Training loss: 1.7458801847785266\n",
"Training loss: 1.7418527005832078\n",
"Training loss: 1.7381157127778921\n",
"Training loss: 1.7355601821881113\n",
"Training loss: 1.7328494567352573\n",
"Training loss: 1.7305794240060899\n",
"Training loss: 1.7285002680983879\n",
"Training loss: 1.72686947268972\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "UT2VXPhp3k2s"
},
"source": [
"## TODO\n",
"1. Add a validation set\n",
"2. Add a test set, and checking accuracy there\n",
"3. Inference for single files\n",
"4. Add calculation for performance in each class"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment