{"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.12.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"colab":{"provenance":[],"gpuType":"T4"},"widgets":{"application/vnd.jupyter.widget-state+json":{"e1d3275b3c7a400aa7ba3427b5fd6622":{"model_module":"@jupyter-widgets/controls","model_name":"VBoxModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"VBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"VBoxView","box_style":"","children":["IPY_MODEL_d477d7768bd44d39a035c5ff1f1b6f6b"],"layout":"IPY_MODEL_66458d41503740879e343a2cd3cf514a"}},"ef35c716b2a04f498a4c5a79e1b0a8d9":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_e294b56e55764e9989f7a27e5a3696e5","placeholder":"​","style":"IPY_MODEL_c1930eee81cd479b8ac4de531254ea2f","value":"<center> <img\nsrc=https://www.kaggle.com/static/images/site-logo.png\nalt='Kaggle'> <br> Create an API token from <a\nhref=\"https://www.kaggle.com/settings/account\" target=\"_blank\">your Kaggle\nsettings page</a> and paste it below. <br> </center>"}},"ae897f58aeca4f84896ee0b664ebad74":{"model_module":"@jupyter-widgets/controls","model_name":"PasswordModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"PasswordModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"PasswordView","continuous_update":true,"description":"API Token:","description_tooltip":null,"disabled":false,"layout":"IPY_MODEL_ccf9e571284e4241a12473586610a542","placeholder":"​","style":"IPY_MODEL_56ce2e0b717b4a3eb7da20357d13badb","value":""}},"31f1e38de7fe4dcd8764594d53b251aa":{"model_module":"@jupyter-widgets/controls","model_name":"ButtonModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ButtonModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ButtonView","button_style":"","description":"Login","disabled":false,"icon":"","layout":"IPY_MODEL_98526e64e7114795ac2a4b97f5d37eee","style":"IPY_MODEL_561930cd571847a59d6d61bdb0e6e001","tooltip":""}},"05c4b6ebb268496db242e516d5b5cad8":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_a0103687482e470cbbb6e6ba69834b17","placeholder":"​","style":"IPY_MODEL_5157d37782d84fcc99a9ffbee163c29b","value":"\n<b>Thank You</b></center>"}},"66458d41503740879e343a2cd3cf514a":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":"center","align_self":null,"border":null,"bottom":null,"display":"flex","flex":null,"flex_flow":"column","grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":"50%"}},"e294b56e55764e9989f7a27e5a3696e5":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"c1930eee81cd479b8ac4de531254ea2f":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"ccf9e571284e4241a12473586610a542":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"56ce2e0b717b4a3eb7da20357d13badb":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"98526e64e7114795ac2a4b97f5d37eee":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"561930cd571847a59d6d61bdb0e6e001":{"model_module":"@jupyter-widgets/controls","model_name":"ButtonStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ButtonStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","button_color":null,"font_weight":""}},"a0103687482e470cbbb6e6ba69834b17":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"5157d37782d84fcc99a9ffbee163c29b":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"05be52151b5041958e12efb02a9cfdeb":{"model_module":"@jupyter-widgets/controls","model_name":"LabelModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"LabelModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"LabelView","description":"","description_tooltip":null,"layout":"IPY_MODEL_4e7953fd28bd4b00b58fe5f81bf44f3b","placeholder":"​","style":"IPY_MODEL_e5663b6cf8694e9b99944b7fbec49ad4","value":"Connecting..."}},"4e7953fd28bd4b00b58fe5f81bf44f3b":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"e5663b6cf8694e9b99944b7fbec49ad4":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"d477d7768bd44d39a035c5ff1f1b6f6b":{"model_module":"@jupyter-widgets/controls","model_name":"LabelModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"LabelModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"LabelView","description":"","description_tooltip":null,"layout":"IPY_MODEL_16755889d16a48d99806af02759d7a35","placeholder":"​","style":"IPY_MODEL_2a27414407654f8a9a73a86a5c0cabd4","value":"Kaggle credentials successfully validated."}},"16755889d16a48d99806af02759d7a35":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"2a27414407654f8a9a73a86a5c0cabd4":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"60cfdcd03dd140f28868e8bae1589618":{"model_module":"@jupyter-widgets/controls","model_name":"VBoxModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"VBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"VBoxView","box_style":"","children":["IPY_MODEL_602ece80e79e470b8daa0067a62015d7"],"layout":"IPY_MODEL_97651cabab54421a8472390e2b6598e8"}},"b02ba47d4ede4a2595ff8949e13d1d9d":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_ba15d6895d684b7fbc08563d07ada0f1","placeholder":"​","style":"IPY_MODEL_eb75cf0b11894c06af3f800f8988fd52","value":"<center> <img\nsrc=https://www.kaggle.com/static/images/site-logo.png\nalt='Kaggle'> <br> Create an API token from <a\nhref=\"https://www.kaggle.com/settings/account\" target=\"_blank\">your Kaggle\nsettings page</a> and paste it below. <br> </center>"}},"6bc72f2ed56048898d6b27254a1ba021":{"model_module":"@jupyter-widgets/controls","model_name":"PasswordModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"PasswordModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"PasswordView","continuous_update":true,"description":"API Token:","description_tooltip":null,"disabled":false,"layout":"IPY_MODEL_abb0fd85a1af408082b82023f2a3fc9a","placeholder":"​","style":"IPY_MODEL_999ec8c81b99490b8fcbbcf6a0ee6bff","value":""}},"9bf849af8e854193aef1eacf436cf9d5":{"model_module":"@jupyter-widgets/controls","model_name":"ButtonModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ButtonModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ButtonView","button_style":"","description":"Login","disabled":false,"icon":"","layout":"IPY_MODEL_db61594769634b3b975a8f13f20d6ed2","style":"IPY_MODEL_e7b3bf6c2d87453ba1e95d2b74b6a606","tooltip":""}},"f927070e973044029f92d513a1a5a181":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_384adeb3e9e14b27b85eb444cbf62025","placeholder":"​","style":"IPY_MODEL_9b1d1f8a75ec4e17b9aea3addb810ec1","value":"\n<b>Thank You</b></center>"}},"97651cabab54421a8472390e2b6598e8":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":"center","align_self":null,"border":null,"bottom":null,"display":"flex","flex":null,"flex_flow":"column","grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":"50%"}},"ba15d6895d684b7fbc08563d07ada0f1":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"eb75cf0b11894c06af3f800f8988fd52":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"abb0fd85a1af408082b82023f2a3fc9a":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"999ec8c81b99490b8fcbbcf6a0ee6bff":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"db61594769634b3b975a8f13f20d6ed2":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"e7b3bf6c2d87453ba1e95d2b74b6a606":{"model_module":"@jupyter-widgets/controls","model_name":"ButtonStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ButtonStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","button_color":null,"font_weight":""}},"384adeb3e9e14b27b85eb444cbf62025":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"9b1d1f8a75ec4e17b9aea3addb810ec1":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"a54b9df6257643fe97121b264e9d4a31":{"model_module":"@jupyter-widgets/controls","model_name":"LabelModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"LabelModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"LabelView","description":"","description_tooltip":null,"layout":"IPY_MODEL_8e394efdc7b14b30abf511588b5dac99","placeholder":"​","style":"IPY_MODEL_ffb3e94e2794420e9fb19a49e8c538d0","value":"Connecting..."}},"8e394efdc7b14b30abf511588b5dac99":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ffb3e94e2794420e9fb19a49e8c538d0":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"602ece80e79e470b8daa0067a62015d7":{"model_module":"@jupyter-widgets/controls","model_name":"LabelModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"LabelModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"LabelView","description":"","description_tooltip":null,"layout":"IPY_MODEL_0e440e1b06d74d61a914b944a71d0b29","placeholder":"​","style":"IPY_MODEL_7db84452525e403abb7f05232a7a86fe","value":"Kaggle credentials successfully validated."}},"0e440e1b06d74d61a914b944a71d0b29":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"7db84452525e403abb7f05232a7a86fe":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}}}},"accelerator":"GPU"},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import keras\nfrom keras import layers","metadata":{"id":"Q9Z88_ZwgBpm","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"inputs = keras.Input(shape=(28, 28, 1))\nx = layers.Conv2D(filters=64, kernel_size=3, activation=\"relu\")(inputs) # Translation Equivariance\n'''\nBecause the same K is used for every (i, j), if you shift the object in the input image by 5 pixels,\nthe \"high activation\" spot in the output map will also shift by exactly 5 pixels. This is called equivariance—the network \"follows\" the feature.\n'''\nx = layers.MaxPooling2D(pool_size=2)(x) # Translation Invariance (Local)\n'''\nIf a feature moves slightly, it might still fall within the same 2 x 2 window.\n Since the pooling layer only cares about the maximum value in that window, the out\nput remains identical. It effectively says: \"I don't care exactly where\n the feature was in this 2 x 2 block, I just care that it was there.\"\n'''\nx = layers.Conv2D(filters=128, kernel_size=3, activation=\"relu\")(x)\nx = layers.MaxPooling2D(pool_size=2)(x)\nx = layers.Conv2D(filters=256, kernel_size=3, activation=\"relu\")(x)\nx = layers.GlobalAveragePooling2D()(x) # Global Invariance\noutputs = layers.Dense(10, activation=\"softmax\")(x)\nmodel = keras.Model(inputs=inputs, outputs=outputs)","metadata":{"id":"0_HTaXFZycZr","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.summary(line_length=80)","metadata":{"id":"FNkjrcsuylV7","outputId":"331102c2-03b1-41cb-f3ab-faa3569289d9","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from keras.datasets import mnist\n(train_images, train_labels), (test_images, test_labels) = mnist.load_data()\ntrain_images = train_images.reshape((60000, 28, 28, 1))\ntrain_images = train_images.astype(\"float32\") / 255\ntest_images = test_images.reshape((10000, 28, 28, 1))\ntest_images = test_images.astype(\"float32\") / 255\nmodel.compile(\noptimizer=\"adam\",\nloss=\"sparse_categorical_crossentropy\",\nmetrics=[\"accuracy\"])\nmodel.fit(train_images, train_labels, epochs=5, batch_size=64)","metadata":{"id":"vHFpmEoA98ji","outputId":"5ae59539-d0e4-478d-978b-ac0bff8514f6","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_loss, test_acc = model.evaluate(test_images, test_labels)\nprint(f\"Test accuracy: {test_acc:.3f}\")","metadata":{"id":"e5V0F_Pm-B4i","outputId":"73014ba4-57b2-4f7d-df8e-b2882267ffe5","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"download_path = '/kaggle/input/competitions/dogs-vs-cats'","metadata":{"id":"FAxV5ngSDL-t","outputId":"d741ec04-2d87-4e06-8169-0287d7274d71","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import zipfile\nwith zipfile.ZipFile(download_path + \"/train.zip\", \"r\") as zip_ref:\n  zip_ref.extractall(\"train\")","metadata":{"id":"tsjawfLtDL2c","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os, shutil, pathlib\noriginal_dir = pathlib.Path(\"train/train\")\nnew_base_dir = pathlib.Path(\"dogs_vs_cats_small\")\ndef make_subset(subset_name, start_index, end_index):\n  for category in (\"cat\", \"dog\"):\n      dir = new_base_dir / subset_name / category\n      os.makedirs(dir)\n      fnames = [f\"{category}.{i}.jpg\" for i in range(start_index, end_index)]\n      for fname in fnames:\n        shutil.copyfile(src=original_dir / fname,\n        dst=dir / fname)\n\nmake_subset(\"train\", start_index=0, end_index=1000)\nmake_subset(\"validation\", start_index=1000, end_index=1500)\nmake_subset(\"test\", start_index=1500, end_index=2500)\n","metadata":{"id":"q1ATpL0JDLyl","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport random\nimport cv2\nimport pathlib\nimport matplotlib.pyplot as plt\n\nfor dir_name in (\"train\", \"validation\", \"test\"):\n    for category in (\"cat\", \"dog\"):\n        path = new_base_dir / dir_name / category\n\n        files = os.listdir(path)\n        print(path, \":\", len(files))\n\n        # filter image files (optional but safer)\n        images = [f for f in files if f.lower().endswith((\".png\", \".jpg\", \".jpeg\"))]\n        if len(images) == 0:\n            print(\"No images found in\", path)\n            continue\n\n        # pick 2 random images\n        sample = random.sample(images, min(2, len(images)))\n\n        plt.figure(figsize=(6, 3))\n\n        for i, img_name in enumerate(sample):\n            img_path = os.path.join(path, img_name)\n            img = cv2.imread(img_path)\n\n            # convert BGR → RGB for correct colors\n            img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n\n            plt.subplot(1, 2, i + 1)\n            plt.imshow(img)\n            plt.title(category)\n            plt.axis(\"off\")\n\n        plt.suptitle(f\"{dir_name} - {category}\")\n        plt.show()","metadata":{"id":"LN4zePlbDLvd","outputId":"8f6b4df3-5914-42af-9cf4-93709d5403a3","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import keras\nfrom keras import layers\ninputs = keras.Input(shape=(180, 180, 3))\nx = layers.Rescaling(1./255)(inputs)\nx = layers.Conv2D(filters=32, kernel_size=3, activation=\"relu\")(x)\nx = layers.MaxPooling2D(pool_size=2)(x)\nx = layers.Conv2D(filters=64, kernel_size=3, activation=\"relu\")(x)\nx = layers.MaxPooling2D(pool_size=2)(x)\nx = layers.Conv2D(filters=128, kernel_size=3, activation=\"relu\")(x)\nx = layers.MaxPooling2D(pool_size=2)(x)\nx = layers.Conv2D(filters=256, kernel_size=3, activation=\"relu\")(x)\nx = layers.MaxPooling2D(pool_size=2)(x)\nx = layers.Conv2D(filters=512, kernel_size=3, activation=\"relu\")(x)\nx = layers.GlobalAveragePooling2D()(x)\noutputs = layers.Dense(1, activation=\"sigmoid\")(x)\nmodel = keras.Model(inputs=inputs, outputs=outputs)","metadata":{"id":"knEFbUiBDLn0","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.summary(line_length=80)","metadata":{"id":"R-Xr8DvlKjH3","outputId":"b8fe4af7-b2af-4538-9611-104ec6908b32","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.compile(loss=\"binary_crossentropy\",\noptimizer=\"adam\",\nmetrics=[\"accuracy\"])","metadata":{"id":"fbHZYncgKjCR","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"batch_size, image_size = 32, (180, 180)\n\nfrom keras.utils import image_dataset_from_directory\ntrain_ds = image_dataset_from_directory(\nnew_base_dir / \"train\",\nimage_size = image_size,\nbatch_size = batch_size)\n\nval_ds = image_dataset_from_directory(\nnew_base_dir / \"validation\",\nimage_size = image_size,\nbatch_size = batch_size)\n\ntest_ds = image_dataset_from_directory(\nnew_base_dir / \"test\",\nimage_size = image_size,\nbatch_size = batch_size)","metadata":{"id":"skMzdjtoKi_C","outputId":"7ec746a5-7a70-4af9-ecce-36ef3e2aa471","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"callbacks = [\nkeras.callbacks.ModelCheckpoint(\nfilepath=\"convnet_from_scratch.keras\",\nsave_best_only=True,\nmonitor=\"val_loss\")\n]\nhistory = model.fit(\ntrain_ds,\nepochs=50,\nvalidation_data=val_ds,\ncallbacks=callbacks)","metadata":{"id":"P92bKGtGKi8B","outputId":"5068ca6f-e9d6-43bd-b576-d93e7c55a27d","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\naccuracy = history.history[\"accuracy\"]\nval_accuracy = history.history[\"val_accuracy\"]\nloss = history.history[\"loss\"]\nval_loss = history.history[\"val_loss\"]\nepochs = range(1, len(accuracy) + 1)\nplt.plot(epochs, accuracy, \"r--\", label=\"Training accuracy\")\nplt.plot(epochs, val_accuracy, \"b\", label=\"Validation accuracy\")\nplt.title(\"Training and validation accuracy\")\nplt.legend()\nplt.figure()\nplt.plot(epochs, loss, \"r--\", label=\"Training loss\")\nplt.plot(epochs, val_loss, \"b\", label=\"Validation loss\")\nplt.title(\"Training and validation loss\")\nplt.legend()\nplt.show()","metadata":{"id":"mqZcFbQTDLiA","outputId":"479ffb61-939e-4d16-c054-cc999f72f22d","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_model = keras.models.load_model(\"convnet_from_scratch.keras\")\ntest_loss, test_acc = test_model.evaluate(test_ds)\nprint(f\"Test accuracy: {test_acc:.3f}\")","metadata":{"id":"c9BEGBSJdZAO","outputId":"da81b446-0539-4fdd-f879-4c10828e01d6","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"x = layers.Dropout(0.25)(x)\noutputs = layers.Dense(1, activation=\"sigmoid\")(x)\nmodel = keras.Model(inputs=inputs, outputs=outputs)\nmodel.summary(line_length = 80)","metadata":{"id":"ZARKafLDdY8N","outputId":"61742b15-69ea-42b6-f639-75f77164b197","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import tensorflow as tf\nimport numpy as np\n\ndata_augmentation_layers = [\nlayers.RandomFlip(\"horizontal\"),\nlayers.RandomRotation(0.1),\nlayers.RandomZoom(0.2)\n]\ndef data_augmentation(images, targets):\n  for layer in data_augmentation_layers:\n    images = layer(images)\n  return images, targets\n\naugmented_train_dataset = train_ds.map(data_augmentation, num_parallel_calls=8)\naugmented_train_dataset = augmented_train_dataset.prefetch(tf.data.AUTOTUNE)\n\nplt.figure(figsize=(10, 10))\nfor image_batch, _ in train_ds.take(1):\n  image = image_batch[0]\n  for i in range(9):\n    ax = plt.subplot(3, 3, i + 1)\n    augmented_image, _ = data_augmentation(image, None)\n    plt.imshow(np.array(augmented_image).astype(\"uint8\")) #2\n    plt.axis(\"off\")","metadata":{"id":"Yn03xUBb-4y9","outputId":"2f4dc480-34ee-4a35-eb07-f68157e570c8","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.compile(loss=\"binary_crossentropy\",\noptimizer=\"adam\",\nmetrics=[\"accuracy\"])\n\ncallbacks = [\nkeras.callbacks.ModelCheckpoint(\nfilepath=\"convnet_from_scratch_with_augmentation.keras\",\nsave_best_only=True,\nmonitor=\"val_loss\")\n]\nhistory = model.fit(\naugmented_train_dataset,\nepochs=100,\nvalidation_data=val_ds,\ncallbacks=callbacks)\ntest_model = keras.models.load_model(\n\"convnet_from_scratch_with_augmentation.keras\")\ntest_loss, test_acc = test_model.evaluate(test_ds)\nprint(f\"Test accuracy: {test_acc:.3f}\")","metadata":{"id":"Q8WlfW_9-4ne","outputId":"102288ed-df7b-473c-cf7d-0066154545b4","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Modularity-hierarchy-reuse","metadata":{"id":"6E3gx-9BLkhx"}},{"cell_type":"code","source":"batch_size = 64\nimage_size = (180, 180)\n\ntrain_dataset = image_dataset_from_directory(\nnew_base_dir / \"train\",\nimage_size=image_size,\nbatch_size=batch_size)\n\nvalidation_dataset = image_dataset_from_directory(\nnew_base_dir / \"validation\",\nimage_size=image_size,\nbatch_size=batch_size)\n\ntest_dataset = image_dataset_from_directory(\nnew_base_dir / \"test\",\nimage_size=image_size,\nbatch_size=batch_size)","metadata":{"id":"dr7GAwv7ZosT","outputId":"c705d065-9044-47f0-c46d-435c37c1285b","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import tensorflow as tf\nfrom keras import layers\n\ndaa_augmentation_layers = [\n    layers.RandomFlip(\"horizontal\"),\n    layers.RandomBrightness(factor=0.3, value_range = [0.0, 1.0]),\n    layers.RandomZoom(0.1),\n    layers.RandomRotation(0.1),\n    layers.RandomContrast(factor=0.5)\n]\n\ndef augment_data(images, targets):\n  for layer in daa_augmentation_layers:\n    images = layer(images)\n  return images, targets\n\naugmented_train_dataset =  train_dataset.map(augment_data, num_parallel_calls=8)\naugmented_train_dataset = augmented_train_dataset.prefetch(tf.data.AUTOTUNE)","metadata":{"id":"thaxVH6wMs0C","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import keras\n\ninputs = keras.Input(shape=(180, 180, 3))\nx = layers.Rescaling(1./255)(inputs)\nx = layers.Conv2D(filters=32, kernel_size=5, use_bias=False)(x)\n\nfor size in [32, 64, 128, 256, 512]:\n    residual = x\n    x = layers.BatchNormalization()(x)\n    x = layers.Activation(\"relu\")(x)\n    x = layers.SeparableConv2D(size, 3, padding=\"same\", use_bias=False)(x)\n    x = layers.BatchNormalization()(x)\n    x = layers.Activation(\"relu\")(x)\n    x = layers.SeparableConv2D(size, 3, padding=\"same\", use_bias=False)(x)\n    x = layers.MaxPooling2D(3, strides=2, padding=\"same\")(x)\n    residual = layers.Conv2D(\n        size, 1, strides=2, padding=\"same\", use_bias=False)(residual)  # for depthwise-pointwise convolution\n        # mode the 'strides' field must match between the maxpooling layer and\n        # the residual skip connection layer i.e. second last layer of residual block\n    x = layers.add([x, residual])\n\nx = layers.GlobalAveragePooling2D()(x)\nx = layers.Dropout(0.5)(x)\noutputs = layers.Dense(1, activation=\"sigmoid\")(x)\nmodel = keras.Model(inputs=inputs, outputs=outputs)","metadata":{"id":"adsxAqYtMtIa","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.summary(line_length = 80)","metadata":{"id":"if0NP-u6MtXq","outputId":"e397fa6c-d708-44ec-e4c9-67998c8573cf","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.compile(loss=\"binary_crossentropy\",\noptimizer=\"adam\",\nmetrics=[\"accuracy\"])\n\nhistory = model.fit(\naugmented_train_dataset,\nepochs=100,\nvalidation_data=validation_dataset)","metadata":{"id":"8n4HC1PJMvFM","outputId":"06ca5d37-1f8a-4a59-cee8-887e6c162e86","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\naccuracy = history.history[\"accuracy\"]\nval_accuracy = history.history[\"val_accuracy\"]\nloss = history.history[\"loss\"]\nval_loss = history.history[\"val_loss\"]\nx_vals = range(1, len(accuracy) + 1)\n\nplot = plt.figure(figsize = (10, 6))\np1, p2 = plot.add_subplot(2,2,1), plot.add_subplot(2,2,2)\np3 = plot.add_subplot(2,1,2)\np3.plot(x_vals, accuracy, \"go--\", label=\"Training accuracy\")\np3.plot(x_vals, val_accuracy, \"bx--\", label=\"Validation accuracy\")\np1.plot(x_vals, loss, \"r+\", label=\"Training loss\")\np2.plot(x_vals, val_loss, \"b\", label=\"Validation loss\")\n\np1.set_title(\"Training loss\")\np2.set_title(\"Validation loss\")\np3.set_title(\"Training and validation accuracy\")\n\np1.legend()\np2.legend()\np3.legend()\n\nplt.show()","metadata":{"id":"V_5OiK8lhMua","outputId":"322b81a8-e13c-4e25-ba95-287faf30c462","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_loss, test_acc = model.evaluate(test_dataset)\nprint(f\"Test accuracy: {test_acc:.2f}\")","metadata":{"id":"oz1iAMzyLdEX","trusted":true},"outputs":[],"execution_count":null}]}