{"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":4477,"databundleVersionId":44220,"sourceType":"competition"}],"dockerImageVersionId":31012,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true},"papermill":{"default_parameters":{},"duration":3398.939582,"end_time":"2024-03-28T14:17:59.233210","environment_variables":{},"exception":null,"input_path":"__notebook__.ipynb","output_path":"__notebook__.ipynb","parameters":{},"start_time":"2024-03-28T13:21:20.293628","version":"2.5.0"},"widgets":{"application/vnd.jupyter.widget-state+json":{"state":{"0436fbe511e64178ab18aa6469f78ea7":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"05f95d827bd5491ba2fe2e69ceb73a5f":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_0436fbe511e64178ab18aa6469f78ea7","max":9619,"min":0,"orientation":"horizontal","style":"IPY_MODEL_93941ff70a8d46e684d0ea8e1186e3e1","value":9619}},"0a06748379254955b2cb1106a773073f":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"0f6732b3002c4a959f90bad5ab693194":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"166dad02e0034363b46d8772524016e6":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","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_9a1a239f33f74b1dbb5f7ebb9a4ca6ea","placeholder":"​","style":"IPY_MODEL_e6d624d3ae684283b4754f03c17c93f5","value":"[Loss: 0.27854976058006287]: 100%"}},"192b1cedb16e4df3ada31ac09ba93a90":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","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":""}},"256b175f224f4e36be1ac4b8689b74b8":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"260543f4eb4e45de8e41c603d4094e19":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_166dad02e0034363b46d8772524016e6","IPY_MODEL_e3b45991d79943ef810098dfcd14c9f0","IPY_MODEL_44828433c4a04e719871201316f9c376"],"layout":"IPY_MODEL_ab161ac4cd67442db3cbde49bfb28ab1"}},"295c3a74754e4a379e016defdeb5bd98":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"2d7d85df2c7e4a07aa28effe1e7da548":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","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_45862aabd4594b5aa7b25eba4b3b8124","placeholder":"​","style":"IPY_MODEL_ae3611ac79fa4146b17d6584e8b25597","value":"100%"}},"30fd9f6de7b643688e37ba724c1e391a":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"3436af69cb604d1280a979513de25f43":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"39a1fbf14b414ef08a27f2f61e3d34cc":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","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_71f36b4829614d328e391e21967953d6","placeholder":"​","style":"IPY_MODEL_192b1cedb16e4df3ada31ac09ba93a90","value":" 192/192 [01:52&lt;00:00,  1.99it/s]"}},"3c51a48b74894c6ba3da1947c6811dad":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","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":""}},"3dd2e5aa55324e1ebd031b8370d88e5c":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"412b05f6dd15486cbe59078ea74e8819":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"44828433c4a04e719871201316f9c376":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","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_295c3a74754e4a379e016defdeb5bd98","placeholder":"​","style":"IPY_MODEL_520513e024f140d79f5a92f36dbd9a02","value":" 9619/9619 [26:45&lt;00:00,  5.55it/s]"}},"45862aabd4594b5aa7b25eba4b3b8124":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"4aafca874c3c4985abb7a677c9091e81":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","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_9209b7ae001d42edb494f8ce29b2bc93","placeholder":"​","style":"IPY_MODEL_790fdbed0086405b8b817fedadb8a4ec","value":"100%"}},"51d54f18264c41fdab37022b9c9a550c":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_d7fd1e5646cc4d95bf4ace659cd37a81","IPY_MODEL_b6d32ee81cbc4c0fa69f0aded412a3e1","IPY_MODEL_a560c204568640aa8d9bdcfb826aea8d"],"layout":"IPY_MODEL_83e2a15f908149a193c3889456499719"}},"520513e024f140d79f5a92f36dbd9a02":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","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":""}},"533ab004484a49549e31a0c0b524a738":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"546c5e0330344efeb5f79160f6df0148":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"5a10d8c898ac43f7859d0d249803fa68":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"5da5cb80833b462594dde95ac018e998":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"68272ade240f443ab6a19edc4f1e3a0f":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","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_5da5cb80833b462594dde95ac018e998","placeholder":"​","style":"IPY_MODEL_f4b6a77411534fceaacbb7493f3263b0","value":" 192/192 [01:53&lt;00:00,  1.97it/s]"}},"6b4bce2d87b84acbb70583ecf56e1cae":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","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_8e85688ca6584943a27434f4f55ab78f","placeholder":"​","style":"IPY_MODEL_9814c888a74b4988817ebedd95a43f0a","value":"[Loss: 0.24986867606639862]: 100%"}},"6d685391bfde464baa91a41b830ef3e9":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","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":""}},"71f36b4829614d328e391e21967953d6":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"790fdbed0086405b8b817fedadb8a4ec":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","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":""}},"7e5e36869e1147a192fe622befaf5f27":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","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":""}},"83e2a15f908149a193c3889456499719":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"8a4b37b15e60435e8f0f0bbb9e61d068":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_6b4bce2d87b84acbb70583ecf56e1cae","IPY_MODEL_05f95d827bd5491ba2fe2e69ceb73a5f","IPY_MODEL_c3f97c3e85cd422db7f80cc50625f38f"],"layout":"IPY_MODEL_9b42b69194394d7aa5067c5ce21ed2d4"}},"8cc91e38a7624215a9d1d5431b76cb35":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_533ab004484a49549e31a0c0b524a738","max":192,"min":0,"orientation":"horizontal","style":"IPY_MODEL_546c5e0330344efeb5f79160f6df0148","value":192}},"8e85688ca6584943a27434f4f55ab78f":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"9209b7ae001d42edb494f8ce29b2bc93":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"93941ff70a8d46e684d0ea8e1186e3e1":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"9814c888a74b4988817ebedd95a43f0a":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","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":""}},"9a1a239f33f74b1dbb5f7ebb9a4ca6ea":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"9b42b69194394d7aa5067c5ce21ed2d4":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"9db3a9c439f6476280749357bfcdd310":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"a560c204568640aa8d9bdcfb826aea8d":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","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_0a06748379254955b2cb1106a773073f","placeholder":"​","style":"IPY_MODEL_6d685391bfde464baa91a41b830ef3e9","value":" 390/390 [00:46&lt;00:00, 11.35it/s]"}},"a8dad63a9adb4ea181fe86abb1bd5982":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","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":""}},"ab161ac4cd67442db3cbde49bfb28ab1":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"ae3611ac79fa4146b17d6584e8b25597":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","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":""}},"aea9ccb065ad4919a44a9565436e4fc1":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_4aafca874c3c4985abb7a677c9091e81","IPY_MODEL_e685d557e6d44f22b202ac56e87ebada","IPY_MODEL_fb520493218b4343b272d8b5638c7289"],"layout":"IPY_MODEL_c72ce158f6054b80a11cb639a02adbda"}},"b4cf7fee80954db0b7fc68e88a323010":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_e6b4cef8703040abbac25855a9f360ce","IPY_MODEL_b5737b1a77f5406dbe34fb2657b8f551","IPY_MODEL_39a1fbf14b414ef08a27f2f61e3d34cc"],"layout":"IPY_MODEL_256b175f224f4e36be1ac4b8689b74b8"}},"b5737b1a77f5406dbe34fb2657b8f551":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_3436af69cb604d1280a979513de25f43","max":192,"min":0,"orientation":"horizontal","style":"IPY_MODEL_d3fa245489d9421c9efa87ac4873f628","value":192}},"b5e38bc2deba465cbb06e602e5f52106":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"b6d32ee81cbc4c0fa69f0aded412a3e1":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_0f6732b3002c4a959f90bad5ab693194","max":390,"min":0,"orientation":"horizontal","style":"IPY_MODEL_3dd2e5aa55324e1ebd031b8370d88e5c","value":390}},"bb977b5aac06440d8b2f2eb5d384bc5c":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_2d7d85df2c7e4a07aa28effe1e7da548","IPY_MODEL_8cc91e38a7624215a9d1d5431b76cb35","IPY_MODEL_68272ade240f443ab6a19edc4f1e3a0f"],"layout":"IPY_MODEL_fc921b1892c0414fa789d71f53bcc387"}},"c3f97c3e85cd422db7f80cc50625f38f":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","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_ed9654c9806342c9b609db2f74b5ead7","placeholder":"​","style":"IPY_MODEL_d0a47aece9f6421abd98c74afa799b3b","value":" 9619/9619 [23:22&lt;00:00,  6.93it/s]"}},"c72ce158f6054b80a11cb639a02adbda":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"ca750541068f40e48ebefedc9a73211f":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"d0a47aece9f6421abd98c74afa799b3b":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","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":""}},"d3fa245489d9421c9efa87ac4873f628":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"d7f053e51b3d44ee8a7fb7f8da78ab55":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"d7fd1e5646cc4d95bf4ace659cd37a81":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","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_412b05f6dd15486cbe59078ea74e8819","placeholder":"​","style":"IPY_MODEL_3c51a48b74894c6ba3da1947c6811dad","value":"100%"}},"e3b45991d79943ef810098dfcd14c9f0":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_ca750541068f40e48ebefedc9a73211f","max":9619,"min":0,"orientation":"horizontal","style":"IPY_MODEL_d7f053e51b3d44ee8a7fb7f8da78ab55","value":9619}},"e685d557e6d44f22b202ac56e87ebada":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_5a10d8c898ac43f7859d0d249803fa68","max":390,"min":0,"orientation":"horizontal","style":"IPY_MODEL_30fd9f6de7b643688e37ba724c1e391a","value":390}},"e6b4cef8703040abbac25855a9f360ce":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","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_9db3a9c439f6476280749357bfcdd310","placeholder":"​","style":"IPY_MODEL_a8dad63a9adb4ea181fe86abb1bd5982","value":"100%"}},"e6d624d3ae684283b4754f03c17c93f5":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","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":""}},"ed9654c9806342c9b609db2f74b5ead7":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}},"f4b6a77411534fceaacbb7493f3263b0":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","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":""}},"fb520493218b4343b272d8b5638c7289":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","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_b5e38bc2deba465cbb06e602e5f52106","placeholder":"​","style":"IPY_MODEL_7e5e36869e1147a192fe622befaf5f27","value":" 390/390 [00:43&lt;00:00, 11.66it/s]"}},"fc921b1892c0414fa789d71f53bcc387":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","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}}},"version_major":2,"version_minor":0}}},"nbformat_minor":4,"nbformat":4,"cells":[{"id":"8536672a","cell_type":"code","source":"import os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\nlabels = ['HandStart', 'FirstDigitTouch', 'BothStartLoadPhase', 'LiftOff',\n       'Replace', 'BothReleased']\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","execution":{"iopub.status.busy":"2025-04-16T14:54:43.236821Z","iopub.execute_input":"2025-04-16T14:54:43.237485Z","iopub.status.idle":"2025-04-16T14:54:43.252736Z","shell.execute_reply.started":"2025-04-16T14:54:43.237465Z","shell.execute_reply":"2025-04-16T14:54:43.252024Z"},"papermill":{"duration":0.027183,"end_time":"2024-03-28T13:21:23.125623","exception":false,"start_time":"2024-03-28T13:21:23.098440","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"e05868c8","cell_type":"code","source":"import os\nimport random\nfrom glob import glob\nfrom tqdm.notebook import tqdm\nimport gc\n\nfrom sklearn.model_selection import train_test_split\nimport numpy as np\nimport pywt\nimport pandas as pd\nfrom sklearn.preprocessing import StandardScaler,Normalizer,MinMaxScaler\nimport scipy\nfrom scipy.signal import butter, lfilter, convolve\nfrom scipy.signal import freqz\nfrom scipy.fftpack import fft, ifft\nimport argparse\nimport matplotlib.pyplot as plt\n\nfrom sklearn import metrics\nimport torch\nfrom torch.utils.data import DataLoader, Dataset\nimport torch.nn as nn\nimport torch.optim as optim","metadata":{"execution":{"iopub.status.busy":"2025-04-16T14:54:43.253441Z","iopub.execute_input":"2025-04-16T14:54:43.253662Z","iopub.status.idle":"2025-04-16T14:54:49.029569Z","shell.execute_reply.started":"2025-04-16T14:54:43.253635Z","shell.execute_reply":"2025-04-16T14:54:49.028998Z"},"papermill":{"duration":5.700323,"end_time":"2024-03-28T13:21:28.835638","exception":false,"start_time":"2024-03-28T13:21:23.135315","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"be1b04ab","cell_type":"code","source":"torch.manual_seed(2021)\nnp.random.seed(2021)\ndevice = 'cuda:0' if torch.cuda.is_available() else 'cpu'\n\nparser = argparse.ArgumentParser()\nparser.add_argument(\"--n_epochs\", type=int, default=1, help=\"number of epochs of training\")\nparser.add_argument(\"--batch_size\", type=int, default=1024, help=\"size of the batches\")\nparser.add_argument(\"--lr\", type=float, default=0.005, help=\"adam's learning rate\")\nparser.add_argument(\"--b1\", type=float, default=0.5, help=\"adam: decay of first order momentum of gradient\")\nparser.add_argument(\"--b2\", type=float, default=0.99, help=\"adam: decay of first order momentum of gradient\")\nparser.add_argument(\"--n_cpu\", type=int, default=4, help=\"number of cpu threads to use during batch generation\")\nparser.add_argument(\"--in_len\", type=int, default=2**10, help=\"length of the input fed to neural net\")\nparser.add_argument(\"--in_channels\", type=int, default=32, help=\"number of signal channels\")\nparser.add_argument(\"--out_channels\", type=int, default=6, help=\"number of classes\")\nparser.add_argument(\"--chunk\", type=int, default=1000, help=\"length of splited chunks\")\nparser.add_argument(\"--lstm_hidden\", type=int, default=1024, help=\"length of splited chunks\")\nopt, unknown = parser.parse_known_args()\nprint(device)","metadata":{"execution":{"iopub.status.busy":"2025-04-16T14:54:49.031171Z","iopub.execute_input":"2025-04-16T14:54:49.031479Z","iopub.status.idle":"2025-04-16T14:54:49.104762Z","shell.execute_reply.started":"2025-04-16T14:54:49.031461Z","shell.execute_reply":"2025-04-16T14:54:49.104076Z"},"papermill":{"duration":0.097998,"end_time":"2024-03-28T13:21:28.943909","exception":false,"start_time":"2024-03-28T13:21:28.845911","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"a92f500a","cell_type":"code","source":"# zip the files as ZIPFILE :)\nimport zipfile\nwith zipfile.ZipFile(\"../input/grasp-and-lift-eeg-detection/test.zip\",\"r\") as z:\n    z.extractall(\".\")\nwith zipfile.ZipFile(\"../input/grasp-and-lift-eeg-detection/train.zip\",\"r\") as z:\n    z.extractall(\".\")","metadata":{"execution":{"iopub.status.busy":"2025-04-16T14:54:49.105610Z","iopub.execute_input":"2025-04-16T14:54:49.105826Z","iopub.status.idle":"2025-04-16T14:55:19.705688Z","shell.execute_reply.started":"2025-04-16T14:54:49.105810Z","shell.execute_reply":"2025-04-16T14:55:19.705149Z"},"papermill":{"duration":29.442235,"end_time":"2024-03-28T13:21:58.395612","exception":false,"start_time":"2024-03-28T13:21:28.953377","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"0c19f561","cell_type":"code","source":"def wavelet_denoising(x, wavelet='db2', level=3):\n    coeff = pywt.wavedec(x, wavelet, mode=\"per\")\n    sigma = (1/0.6745) * madev(coeff[-level])\n    uthresh = sigma * np.sqrt(2 * np.log(len(x)))\n    coeff[1:] = (pywt.threshold(i, value=uthresh, mode='hard') for i in coeff[1:])\n    return pywt.waverec(coeff, wavelet, mode='per')\ndef madev(d, axis=None):\n    \"\"\" Mean absolute deviation of a signal \"\"\"\n    return np.mean(np.absolute(d - np.mean(d, axis)), axis)","metadata":{"execution":{"iopub.status.busy":"2025-04-16T14:55:19.706398Z","iopub.execute_input":"2025-04-16T14:55:19.706593Z","iopub.status.idle":"2025-04-16T14:55:19.712368Z","shell.execute_reply.started":"2025-04-16T14:55:19.706577Z","shell.execute_reply":"2025-04-16T14:55:19.711712Z"},"papermill":{"duration":0.019072,"end_time":"2024-03-28T13:21:58.425065","exception":false,"start_time":"2024-03-28T13:21:58.405993","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"dbe6440f","cell_type":"code","source":"%%time\ndef read_csv(data, events):\n    x = pd.read_csv(data)\n    y = pd.read_csv(events)\n    id = '_'.join(x.iloc[0, 0].split('_')[:-1])\n    x = x.iloc[:,1:].values\n    y = y.iloc[:,1:].values\n    return x, y\n    \n\ntrainset = []\ngt = []\nfor filename in tqdm(os.listdir('./train')):\n    if 'data' in filename:\n        data_file_name = os.path.join('./train', filename)\n        id = filename.split('.')[0]\n        events_file_name = os.path.join('./train', '_'.join(id.split('_')[:-1]) + '_events.csv')\n        x, y = read_csv(data_file_name, events_file_name)\n        x = wavelet_denoising(x)\n        trainset.append(x.T.astype(np.float32))\n        gt.append(y.T.astype(np.float32))","metadata":{"execution":{"iopub.status.busy":"2025-04-16T14:55:19.712968Z","iopub.execute_input":"2025-04-16T14:55:19.713202Z","iopub.status.idle":"2025-04-16T14:56:38.152173Z","shell.execute_reply.started":"2025-04-16T14:55:19.713186Z","shell.execute_reply":"2025-04-16T14:56:38.151449Z"},"papermill":{"duration":113.166714,"end_time":"2024-03-28T13:23:51.620981","exception":false,"start_time":"2024-03-28T13:21:58.454267","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"1563b876","cell_type":"markdown","source":"# DataSet For ResCNN","metadata":{"papermill":{"duration":0.009061,"end_time":"2024-03-28T13:21:58.444563","exception":false,"start_time":"2024-03-28T13:21:58.435502","status":"completed"},"tags":[]}},{"id":"19d3556d","cell_type":"code","source":"valid_dataset = trainset[-2:]\nvalid_gt = gt[-2:]\ntrainset = trainset[:-2]\ngt = gt[:-2]","metadata":{"execution":{"iopub.status.busy":"2025-04-16T14:56:38.153216Z","iopub.execute_input":"2025-04-16T14:56:38.153432Z","iopub.status.idle":"2025-04-16T14:56:38.157404Z","shell.execute_reply.started":"2025-04-16T14:56:38.153413Z","shell.execute_reply":"2025-04-16T14:56:38.156745Z"},"papermill":{"duration":0.01773,"end_time":"2024-03-28T13:23:51.649263","exception":false,"start_time":"2024-03-28T13:23:51.631533","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"5ed3983d","cell_type":"code","source":"def resample_data(gt, chunk_size=opt.chunk):\n    \"\"\"\n    split long signals to smaller chunks, discard no-events chunks  \n    \"\"\"\n    total_discard_chunks = 0\n    mean_val = []\n    threshold = 0.01\n    index = []\n    \n    for i in range(len(gt)):\n        for j in range(0, gt[i].shape[1], chunk_size):\n            mean_val.append(np.mean(gt[i][:, j:min(gt[i].shape[1],j+chunk_size)]))\n            if mean_val[-1] < threshold and j > 0:  # discard chunks with low events time\n                total_discard_chunks += 1\n                index.extend([(i, k) for k in range(j, min(gt[i].shape[1],j+chunk_size), chunk_size//100)])\n            else:\n                index.extend([(i, k) for k in range(j, min(gt[i].shape[1],j+chunk_size))])\n\n    plt.plot([0, len(mean_val)], [threshold, threshold], color='r')\n    plt.scatter(range(len(mean_val)), mean_val, s=1)\n    plt.show()\n    print('Total number of chunks discarded: {} chunks'.format(total_discard_chunks))\n    print('{}% data'.format(total_discard_chunks/len(mean_val)))\n    del mean_val\n    gc.collect()\n    return index","metadata":{"execution":{"iopub.status.busy":"2025-04-16T14:56:38.158059Z","iopub.execute_input":"2025-04-16T14:56:38.158357Z","iopub.status.idle":"2025-04-16T14:56:38.176323Z","shell.execute_reply.started":"2025-04-16T14:56:38.158328Z","shell.execute_reply":"2025-04-16T14:56:38.175685Z"},"papermill":{"duration":0.023371,"end_time":"2024-03-28T13:23:51.682499","exception":false,"start_time":"2024-03-28T13:23:51.659128","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"2383f6fe","cell_type":"code","source":"%%time\nclass EEGSignalDataset(Dataset):\n    def __init__(self, data, gt, soft_label=True, train=True):\n        self.data = data\n        self.gt = gt\n        self.train = train\n        self.soft_label = soft_label\n        if train:\n            self.index = resample_data(gt)\n        else:\n            self.index = [(i, j) for i in range(len(data)) for j in range(data[i].shape[1])]\n    \n    def __getitem__(self, i):\n        i, j = self.index[i]\n        raw_data, label = self.data[i][:,max(0, j-opt.in_len+1):j+1], \\\n                self.gt[i][:,j]\n        pad = opt.in_len - raw_data.shape[1]\n        if pad:\n            raw_data = np.pad(raw_data, ((0,0),(pad,0)), 'constant',constant_values=0)\n\n        raw_data, label = torch.from_numpy(raw_data.astype(np.float32)),\\\n                            torch.from_numpy(label.astype(np.float32))\n        if self.soft_label:\n            label[label < .05] = .05\n        return raw_data, label\n            \n    \n    def __len__(self):\n        return len(self.index)\n    \ndataset = EEGSignalDataset(trainset, gt) \ndataloader = DataLoader(dataset, batch_size = opt.batch_size,\\\n                                       num_workers = opt.n_cpu, shuffle=True)\nprint(len(dataset))\ntestset = EEGSignalDataset(valid_dataset, valid_gt, train=False, soft_label=False) \ntestloader = DataLoader(testset, batch_size = opt.batch_size,\\\n                                       num_workers = opt.n_cpu, shuffle=False)\nvalid_gt = np.concatenate(valid_gt, axis=1)","metadata":{"execution":{"iopub.status.busy":"2025-04-16T14:56:38.179140Z","iopub.execute_input":"2025-04-16T14:56:38.179373Z","iopub.status.idle":"2025-04-16T14:56:40.440656Z","shell.execute_reply.started":"2025-04-16T14:56:38.179357Z","shell.execute_reply":"2025-04-16T14:56:40.440022Z"},"papermill":{"duration":2.963691,"end_time":"2024-03-28T13:23:54.656423","exception":false,"start_time":"2024-03-28T13:23:51.692732","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"c611d9bd","cell_type":"markdown","source":"# ResCNN","metadata":{"papermill":{"duration":0.01212,"end_time":"2024-03-28T13:23:54.681024","exception":false,"start_time":"2024-03-28T13:23:54.668904","status":"completed"},"tags":[]}},{"id":"25f9ab21","cell_type":"code","source":"class NNet(nn.Module):\n    def __init__(self, in_channels=opt.in_channels, out_channels=opt.out_channels):\n        super(NNet, self).__init__()\n        self.hidden = 32\n        self.net = nn.Sequential(\n            nn.BatchNorm1d(opt.in_channels),\n            nn.Conv1d(opt.in_channels, opt.in_channels, 5, padding=2),\n            nn.Conv1d(opt.in_channels, self.hidden, 16, stride=16),\n            nn.LeakyReLU(0.1),\n            nn.Conv1d(self.hidden, self.hidden, 7, padding=3),\n        )\n        for i in range(2):\n            self.net.add_module('conv{}'.format(i), \\\n                                self.__block(self.hidden, self.hidden)) # 16\n        \n        self.mid = nn.Sequential(\n            self.__block(self.hidden, self.hidden),\n            self.__block(self.hidden, self.hidden)\n        ) # 4\n        self.final = nn.Sequential(\n            nn.Linear(256, 64),\n            nn.LeakyReLU(0.1),\n            nn.Linear(64, 6),\n            nn.Sigmoid()\n        )\n        \n    def __block(self, inchannels, outchannels):\n        return nn.Sequential(\n            nn.MaxPool1d(2, 2),\n            nn.Conv1d(inchannels, outchannels, 5, padding=2),\n            nn.LeakyReLU(0.1),\n            nn.BatchNorm1d(outchannels),\n            nn.Conv1d(outchannels, outchannels, 5, padding=2),\n            nn.LeakyReLU(0.1)\n        )\n    \n    def forward(self, x):\n        x = self.net(x)\n        y = self.mid(x)\n        y = torch.cat((x[..., -4:], y), dim=-1).view(x.shape[0], -1)\n        return self.final(y)","metadata":{"execution":{"iopub.status.busy":"2025-04-16T14:56:40.441664Z","iopub.execute_input":"2025-04-16T14:56:40.441930Z","iopub.status.idle":"2025-04-16T14:56:40.449811Z","shell.execute_reply.started":"2025-04-16T14:56:40.441904Z","shell.execute_reply":"2025-04-16T14:56:40.448984Z"},"papermill":{"duration":0.02598,"end_time":"2024-03-28T13:23:54.718792","exception":false,"start_time":"2024-03-28T13:23:54.692812","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"f638361e","cell_type":"code","source":"%%time\nnnet = NNet()\nnnet.to(device)\nloss_fnc = nn.BCELoss()\nadam = optim.Adam(nnet.parameters(), lr=opt.lr, betas=(opt.b1, opt.b2))\nloss_his, train_loss, valid_auc, train_auc = [], [], [], []\nnnet.train()\nfor epoch in range(opt.n_epochs):\n    p_bar = tqdm(dataloader)\n    for i, (x, y) in enumerate(p_bar):\n        x, y = x.to(device), y.to(device)\n        pred = nnet(x)\n        loss = loss_fnc(pred.squeeze(dim=-1), y)\n        adam.zero_grad()\n        loss.backward()\n        nn.utils.clip_grad_value_(nnet.parameters(), 2.)\n        adam.step()\n        train_loss.append(loss.item())\n        p_bar.set_description('[Loss: {}]'.format(train_loss[-1]))\n        if i % 50 == 0:\n            loss_his.append(np.mean(train_loss))\n            train_loss.clear()\n#         if i % 1500 == 0:\n#             y[y<0.1]=0\n#             train_auc.append(metrics.roc_auc_score(y.detach().cpu().numpy(), \\\n#                                 pred.detach().cpu().numpy()))\n#             valid_auc.append(calc_valid_auc(nnet))\n    print('[Epoch {}/{}] [Loss: {}]'.format(epoch+1, opt.n_epochs, loss_his[-1]))\n    \ntorch.save(nnet.state_dict(), 'model.pt')","metadata":{"execution":{"iopub.status.busy":"2025-04-16T14:56:40.450719Z","iopub.execute_input":"2025-04-16T14:56:40.450976Z","execution_failed":"2025-04-16T14:59:27.937Z"},"papermill":{"duration":1405.418194,"end_time":"2024-03-28T13:47:20.147947","exception":false,"start_time":"2024-03-28T13:23:54.729753","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"bb477406","cell_type":"code","source":"plt.plot(range(len(loss_his)), loss_his, label='loss')\nplt.legend()\nplt.show()","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.937Z"},"papermill":{"duration":0.280995,"end_time":"2024-03-28T13:47:20.440755","exception":false,"start_time":"2024-03-28T13:47:20.159760","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"c98f8313","cell_type":"code","source":"nnet.eval()\ny_pred = []\nwith torch.no_grad():\n    for x, _ in tqdm(testloader):\n        x = x.to(device)\n        pred = nnet(x).detach().cpu().numpy()\n        y_pred.append(pred)\ny_pred = np.concatenate(y_pred, axis=0)","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.937Z"},"papermill":{"duration":43.103749,"end_time":"2024-03-28T13:48:03.557093","exception":false,"start_time":"2024-03-28T13:47:20.453344","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"1cb0b37c","cell_type":"code","source":"def plot_roc(y_true, y_pred):\n    fig, axs = plt.subplots(3, 2, figsize=(15,15))\n    for i, label in enumerate(labels):\n        fpr, tpr, _ = metrics.roc_curve(y_true[i], y_pred[i])\n        ax = axs[i//2, i%2]\n        ax.plot(fpr, tpr,linewidth=3)\n        ax.set_title(label+\" ROC\")\n        ax.plot([0, 1], [0, 1], 'k--')\n        plt.xlim([0.0, 1.0])\n        plt.ylim([0.0, 1.0])\n        plt.xlabel('False Positive Rate')\n        plt.ylabel('True Positive Rate')\n\n    plt.show()","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.937Z"},"papermill":{"duration":0.025062,"end_time":"2024-03-28T13:48:03.595717","exception":false,"start_time":"2024-03-28T13:48:03.570655","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"98fe8e65","cell_type":"code","source":"plot_roc(valid_gt, y_pred.T)\nprint('auc roc: ', metrics.roc_auc_score(valid_gt.T, y_pred))","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.937Z"},"papermill":{"duration":2.645501,"end_time":"2024-03-28T13:48:06.254244","exception":false,"start_time":"2024-03-28T13:48:03.608743","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"17c6d3ad","cell_type":"code","source":"!pip install tensorboardX -q\n\nfrom tensorboardX import SummaryWriter\n\nnnet = NNet()\nnnet.to(device)\nx.to(device)\n# 创建一个SummaryWriter实例\nwriter = SummaryWriter('./runs/model_visualization')\n\n# 添加模型的计算图\nwriter.add_graph(nnet, x)\n\n# 关闭SummaryWriter\nwriter.close()","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.937Z"},"papermill":{"duration":19.206247,"end_time":"2024-03-28T13:48:25.475233","exception":false,"start_time":"2024-03-28T13:48:06.268986","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"c007617c","cell_type":"markdown","source":"# DataSet For LSTM","metadata":{"_kg_hide-input":false,"papermill":{"duration":0.014463,"end_time":"2024-03-28T13:48:25.504661","exception":false,"start_time":"2024-03-28T13:48:25.490198","status":"completed"},"tags":[]}},{"id":"f66604f4","cell_type":"code","source":"%%time\ndef read_csv(data, events):\n    x = pd.read_csv(data)\n    y = pd.read_csv(events)\n    id = '_'.join(x.iloc[0, 0].split('_')[:-1])\n    x = x.iloc[:,1:].values\n    y = y.iloc[:,1:].values\n    return x, y\n    \n\ntrainset = []\ngt = []\nfor filename in tqdm(os.listdir('./train')):\n    if 'data' in filename:\n        data_file_name = os.path.join('./train', filename)\n        id = filename.split('.')[0]\n        events_file_name = os.path.join('./train', '_'.join(id.split('_')[:-1]) + '_events.csv')\n        x, y = read_csv(data_file_name, events_file_name)\n        x = wavelet_denoising(x)\n        trainset.append(x.astype(np.float32))\n        gt.append(y.astype(np.float32))","metadata":{"_kg_hide-input":false,"execution":{"execution_failed":"2025-04-16T14:59:27.937Z"},"papermill":{"duration":112.267353,"end_time":"2024-03-28T13:50:17.786843","exception":false,"start_time":"2024-03-28T13:48:25.519490","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"1945c7e0","cell_type":"code","source":"valid_dataset = trainset[-2:]\nvalid_gt = gt[-2:]\ntrainset = trainset[:-2]\ngt = gt[:-2]","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.937Z"},"papermill":{"duration":0.022372,"end_time":"2024-03-28T13:50:17.824048","exception":false,"start_time":"2024-03-28T13:50:17.801676","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"c119e5f9","cell_type":"code","source":"gt[0].shape","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.938Z"},"papermill":{"duration":0.023431,"end_time":"2024-03-28T13:50:17.863389","exception":false,"start_time":"2024-03-28T13:50:17.839958","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"3393cd52","cell_type":"markdown","source":"# DataLoader For LSTM","metadata":{"papermill":{"duration":0.014262,"end_time":"2024-03-28T13:50:17.892049","exception":false,"start_time":"2024-03-28T13:50:17.877787","status":"completed"},"tags":[]}},{"id":"820c69c0","cell_type":"code","source":"def resample_data_time_var(gt, chunk_size=opt.chunk):\n    \"\"\"\n    split long signals to smaller chunks, discard no-events chunks  \n    \"\"\"\n    total_discard_chunks = 0\n    mean_val = []\n    threshold = 0.01\n    index = []\n    \n    for i in range(len(gt)):\n        for j in range(0, gt[i].shape[0], chunk_size):\n            mean_val.append(np.mean(gt[i][j:min(gt[i].shape[0],j+chunk_size), :]))\n            if mean_val[-1] < threshold and j > 0: \n                total_discard_chunks += 1\n                index.extend([(i, k) for k in range(j, min(gt[i].shape[0],j+chunk_size), chunk_size//100)])\n            else:\n                index.extend([(i, k) for k in range(j, min(gt[i].shape[0],j+chunk_size))])\n\n    del mean_val\n    gc.collect()\n    return index","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.938Z"},"papermill":{"duration":0.02529,"end_time":"2024-03-28T13:50:17.931598","exception":false,"start_time":"2024-03-28T13:50:17.906308","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"2bc13f9b","cell_type":"code","source":"%%time\nclass EEGSignalDataset(Dataset):\n    def __init__(self, data, gt, soft_label=True, train=True):\n        self.data = data\n        self.gt = gt\n        self.train = train\n        self.soft_label = soft_label\n        if train:\n            self.index = resample_data_time_var(gt)\n        else:\n            self.index = [(i, j) for i in range(len(data)) for j in range(data[i].shape[0])]\n    \n    def __getitem__(self, i):\n        i, j = self.index[i]\n        raw_data, label = self.data[i][max(0, j-opt.in_len+1):j+1,:], \\\n                self.gt[i][j,:]\n        pad = opt.in_len - raw_data.shape[0]\n        if pad:\n            raw_data = np.pad(raw_data, ((pad,0),(0,0)), 'constant',constant_values=0)\n\n        raw_data, label = torch.from_numpy(raw_data.astype(np.float32)),\\\n                            torch.from_numpy(label.astype(np.float32))\n        if self.soft_label:\n            label[label < .05] = .05\n        return raw_data, label\n            \n    \n    def __len__(self):\n        return len(self.index)\n    \ndataset = EEGSignalDataset(trainset, gt) \ndataloader = DataLoader(dataset, batch_size = opt.batch_size,\\\n                                       num_workers = opt.n_cpu, shuffle=True)\nprint(len(dataset))\ntestset = EEGSignalDataset(valid_dataset, valid_gt, train=False, soft_label=False) \ntestloader = DataLoader(testset, batch_size = opt.batch_size,\\\n                                       num_workers = opt.n_cpu, shuffle=False)\nvalid_gt = np.concatenate(valid_gt, axis=0)","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.938Z"},"papermill":{"duration":3.07832,"end_time":"2024-03-28T13:50:21.024015","exception":false,"start_time":"2024-03-28T13:50:17.945695","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"fab20944","cell_type":"markdown","source":"# Neural NetWork","metadata":{"papermill":{"duration":0.014266,"end_time":"2024-03-28T13:50:21.053377","exception":false,"start_time":"2024-03-28T13:50:21.039111","status":"completed"},"tags":[]}},{"id":"2008b0f0","cell_type":"code","source":"class LSTMNet(nn.Module):\n    def __init__(self, in_channels=opt.in_channels, out_channels=opt.out_channels):\n        super(LSTMNet, self).__init__()\n        self.hidden = 32\n        self.seq = opt.in_len\n        self.LSTM = nn.Sequential(\n        nn.LSTM(input_size = opt.in_channels,\n                hidden_size =opt.in_channels,\n                batch_first = True,dropout = 0.8,bidirectional = False),\n        )  \n        self.MLP = nn.Sequential(\n        nn.Linear(160,80),\n        nn.LeakyReLU(0.1),\n        nn.Linear(80,6),\n        nn.Sigmoid()\n        )\n        self.ConvNet = nn.Sequential(\n        nn.BatchNorm1d(opt.in_channels),\n        nn.Conv1d(opt.in_channels, opt.in_channels, 5, padding=2),\n        nn.Conv1d(opt.in_channels, self.hidden, 16, stride=16),\n        nn.LeakyReLU(0.1),\n        nn.Conv1d(self.hidden, self.hidden, 7, padding=3),\n        self.__block(self.hidden,self.hidden),\n        self.__block(self.hidden,self.hidden),\n        nn.Conv1d(opt.in_channels, self.hidden, 4, stride=4),\n        )\n        self.Hidden = nn.Sequential(\n        self.__block(self.hidden,self.hidden),\n        self.__block(self.hidden,self.hidden)\n        )\n    def __block(self, inchannels, outchannels):\n        return nn.Sequential(\n            nn.MaxPool1d(2, 2),\n            nn.Conv1d(inchannels, outchannels, 5, padding=2),\n            nn.LeakyReLU(0.1),\n            nn.BatchNorm1d(outchannels),\n            nn.Conv1d(outchannels, outchannels, 5, padding=2),\n            nn.LeakyReLU(0.1)\n        )\n    def forward(self, x):\n        x,_ = self.LSTM(x)\n        x = x.permute(0,2,1)\n        x = self.ConvNet(x)\n        y = self.Hidden(x)\n        y = torch.cat((x[...,-4:],y),dim = 2).view(x.shape[0],-1)\n        y = self.MLP(y)\n        return y","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.938Z"},"papermill":{"duration":0.031523,"end_time":"2024-03-28T13:50:21.099539","exception":false,"start_time":"2024-03-28T13:50:21.068016","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"bde97d5a","cell_type":"code","source":"%%time\nlstmnet = LSTMNet()\nlstmnet.to(device)\nloss_fnc = nn.BCELoss()\nadam = optim.Adam(lstmnet.parameters(), lr=opt.lr, betas=(opt.b1, opt.b2))\nloss_his, train_loss, valid_auc, train_auc = [], [], [], []\nlstmnet.train()\nfor epoch in range(opt.n_epochs):\n    p_bar = tqdm(dataloader)\n    for i, (x, y) in enumerate(p_bar):\n        x, y = x.to(device), y.to(device)\n        pred = lstmnet(x)\n        loss = loss_fnc(pred.squeeze(dim=-1), y)\n        adam.zero_grad()\n        loss.backward()\n        nn.utils.clip_grad_value_(lstmnet.parameters(), 2.)\n        adam.step()\n        train_loss.append(loss.item())\n        p_bar.set_description('[Loss: {}]'.format(train_loss[-1]))\n        if i % 50 == 0:\n            loss_his.append(np.mean(train_loss))\n            train_loss.clear()\n#         if i % 1500 == 0:\n#             y[y<0.1]=0\n#             train_auc.append(metrics.roc_auc_score(y.detach().cpu().numpy(), \\\n#                                 pred.detach().cpu().numpy()))\n#             valid_auc.append(calc_valid_auc(lstmnet))\n    print('[Epoch {}/{}] [Loss: {}]'.format(epoch+1, opt.n_epochs, loss_his[-1]))\n    \ntorch.save(lstmnet.state_dict(), 'model.pt')","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.938Z"},"papermill":{"duration":1605.829534,"end_time":"2024-03-28T14:17:06.943154","exception":false,"start_time":"2024-03-28T13:50:21.113620","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"426e6e5d","cell_type":"code","source":"plt.plot(range(len(loss_his)), loss_his, label='loss')\nplt.legend()\nplt.show()","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.938Z"},"papermill":{"duration":0.294086,"end_time":"2024-03-28T14:17:07.252748","exception":false,"start_time":"2024-03-28T14:17:06.958662","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"c1a38fb7","cell_type":"code","source":"lstmnet.eval()\ny_pred = []\nwith torch.no_grad():\n    for x, _ in tqdm(testloader):\n        x = x.to(device)\n        pred = lstmnet(x).detach().cpu().numpy()\n        y_pred.append(pred)\ny_pred = np.concatenate(y_pred, axis=0)","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.938Z"},"papermill":{"duration":46.055279,"end_time":"2024-03-28T14:17:53.323486","exception":false,"start_time":"2024-03-28T14:17:07.268207","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"31855a90","cell_type":"code","source":"def plot_roc(y_true, y_pred):\n    fig, axs = plt.subplots(3, 2, figsize=(15,15))\n    for i, label in enumerate(labels):\n        fpr, tpr, _ = metrics.roc_curve(y_true[:,i], y_pred[:,i])\n        ax = axs[i//2, i%2]\n        ax.plot(fpr, tpr,linewidth=3)\n        ax.set_title(label+\" ROC\")\n        ax.plot([0, 1], [0, 1], 'k--')\n        plt.xlim([0.0, 1.0])\n        plt.ylim([0.0, 1.0])\n        plt.xlabel('False Positive Rate')\n        plt.ylabel('True Positive Rate')\n\n    plt.show()","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.938Z"},"papermill":{"duration":0.027265,"end_time":"2024-03-28T14:17:53.367700","exception":false,"start_time":"2024-03-28T14:17:53.340435","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"6c17ffad","cell_type":"code","source":"valid_gt.shape","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.938Z"},"papermill":{"duration":0.02624,"end_time":"2024-03-28T14:17:53.410437","exception":false,"start_time":"2024-03-28T14:17:53.384197","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"6fdc4cb9","cell_type":"code","source":"plot_roc(valid_gt, y_pred)\nprint('auc roc: ', metrics.roc_auc_score(valid_gt, y_pred))","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.938Z"},"papermill":{"duration":2.486567,"end_time":"2024-03-28T14:17:55.914156","exception":false,"start_time":"2024-03-28T14:17:53.427589","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"2d065f63","cell_type":"markdown","source":"# Model Visualization","metadata":{"papermill":{"duration":0.017219,"end_time":"2024-03-28T14:17:55.950523","exception":false,"start_time":"2024-03-28T14:17:55.933304","status":"completed"},"tags":[]}},{"id":"9e796f58","cell_type":"code","source":"from tensorboardX import SummaryWriter\nlstmnet = LSTMNet()\nlstmnet.to(device)\nx.to(device)\n# 创建一个SummaryWriter实例\nwriter = SummaryWriter('./runs/model_visualization')\n\n# 添加模型的计算图\nwriter.add_graph(lstmnet, x)\n\n# 关闭SummaryWriter\nwriter.close()","metadata":{"execution":{"execution_failed":"2025-04-16T14:59:27.938Z"},"papermill":{"duration":0.412339,"end_time":"2024-03-28T14:17:56.379996","exception":false,"start_time":"2024-03-28T14:17:55.967657","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"4d0726fd-d63d-450f-9a3e-51a757079b9f","cell_type":"code","source":"%%time\n\n!pip install torch==1.13.0 --upgrade &> null\n!pip install ecgmentations &> null # library with 1d signal augmentations\n!pip install git+https://github.com/rostepifanov/nnspt@release_v0.0.2 &> null # library with 1d CNNs","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"cb50e696-a8b3-4293-b47c-0e30f4fb3667","cell_type":"code","source":"import os\nimport torch\nimport random\nimport numpy as np\n\nseed = 1996\n\nrandom.seed(seed)\n\nnp.random.seed(seed)\n\ntorch.manual_seed(seed)\ntorch.cuda.manual_seed(seed)\ntorch.cuda.manual_seed_all(seed)\n\ntorch.backends.cudnn.determenistic = True\ntorch.use_deterministic_algorithms(True)\n\nos.environ['PYTHONHASHSEED'] = str(seed)\n\ndevice = 'cuda:0' if torch.cuda.is_available() else 'cpu'\n\nprint(device)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"21ca843f-fed1-4e42-833e-c7186734df68","cell_type":"code","source":"%%time\n\nfrom pathlib import Path\nfrom zipfile import ZipFile\n\nlabels = [ 'HandStart', 'FirstDigitTouch', 'BothStartLoadPhase', 'LiftOff', 'Replace', 'BothReleased' ]\n\nzipdir = Path.cwd().parent / 'input' / 'grasp-and-lift-eeg-detection'\n\nfor zipfile in zipdir.glob('*.zip'):\n    with ZipFile(zipfile, 'r') as zf:\n        zf.extractall()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"243c9b26-1e9b-44d2-a1e4-fd8d195e0527","cell_type":"code","source":"%%time\n\nimport pandas as pd\nfrom tqdm import tqdm\n\nxs = []\nys = []\nys_ = []\n\ntraindir = Path('train')\n\nfor datapath in tqdm([*sorted(traindir.glob('*_data.csv'))]):\n    eventpath = datapath.parent / ( datapath.stem[:-5] + '_events.csv' )\n\n    x = pd.read_csv(datapath)\n    y = pd.read_csv(eventpath)\n\n    x = x.iloc[:,1:].values\n    y_ = y.iloc[:,1:].values\n\n    xs.append(x.astype(np.float32))\n    ys.append(y_.astype(np.uint8))\n\nxs_train = xs[:-2]\nys_train = ys[:-2]\n\nxs_valid = xs[-2:]\nys_valid = ys[-2:]","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"23069bee-6214-4b1d-99e4-87a544a35edd","cell_type":"code","source":"import ecgmentations as E\n\nfrom torch.utils.data import DataLoader, Dataset\n\nclass EEGDataset(Dataset):\n    def __init__(self, x, y, augs=dict, train=False):\n        self.x = x\n        self.y = y\n        self.augs = augs\n        \n        self.train = train\n\n    def __getitem__(self, idx):\n        eeg = self.x[idx]\n        mask = self.y[idx]\n\n        if self.train:\n            length = mask.shape[0]\n\n            size = 5000\n            smask = (np.sum(mask[:-size], axis=1) > 0).astype(np.uint8)\n            smask = smask * 5 + 1\n            p = smask / smask.sum()\n\n            jdx = np.random.choice(length-size, p=p)\n\n            eeg = eeg[jdx:jdx+size]\n            mask = mask[jdx:jdx+size]\n\n        auged = self.augs(ecg=eeg, mask=mask)\n        eeg, mask = auged['ecg'], auged['mask']\n\n        return eeg.T, mask.T\n\n    def __len__(self):\n        return len(self.x)\n\naugs = E.Sequential([\n    E.TimeCrop(length=5000, p=1.0),\n])\n\ndataset = EEGDataset(xs_train, ys_train, augs, True) \ntrain_dataloader = DataLoader(dataset, batch_size=25, num_workers=3, shuffle=True)\n\ndataset = EEGDataset(xs_train, ys_train) \ntrain_dataloader_ = DataLoader(dataset, batch_size=1, num_workers=3, shuffle=False)\n\ndataset = EEGDataset(xs_valid, ys_valid)\nvalid_dataloader = DataLoader(dataset, batch_size=1, num_workers=3, shuffle=False)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"fade9124-cdf4-4dc3-9e58-9cc58beb245e","cell_type":"code","source":"import copy\nimport torch.nn.functional as F\n\nfrom sklearn import metrics\nfrom nnspt.segmentation.unet import Unet\n\nmodel = Unet(in_channels=32, out_channels=6, encoder='timm-efficientnet-b1')\nmodel.to(device)\n\nnepochs = 1000\n\nopt = torch.optim.AdamW(model.parameters(), lr=0.00175)\nshed = torch.optim.lr_scheduler.CosineAnnealingLR(opt, nepochs*len(train_dataloader))\n\nloss_his, train_loss = [], []\n\nbest_score = 0.\nbest_state_dict = copy.deepcopy(model.state_dict())\n\nfor epoch in range(nepochs):\n    model.train()\n\n    for i, (eeg_batch, mask_batch) in enumerate(train_dataloader):\n        eeg_batch, mask_batch = eeg_batch.to(device), mask_batch.to(device)\n\n        logits = model(eeg_batch)\n        loss = F.binary_cross_entropy_with_logits(logits, mask_batch.float())\n        loss.backward()\n\n        opt.step()\n        shed.step()\n        opt.zero_grad()\n\n        train_loss.append(loss.item())\n\n    if (epoch + 1) % 25 == 0:\n        loss_his.append(np.mean(train_loss))\n        train_loss.clear()\n\n        print('[Epoch {}/{}] [Loss: {}]'.format(epoch+1, nepochs, loss_his[-1]))\n        \n        model.eval()\n\n        y_pred = []\n\n        size = 10000\n\n        for eeg_batch, _ in tqdm(valid_dataloader):\n            for idx in range((eeg_batch.shape[-1] + size - 1) // size):\n                with torch.no_grad():\n                    eeg_batch_ = eeg_batch[:, :, idx*size: (idx+1)*size].to(device)\n\n                    logits = model(eeg_batch_)\n                    probs = torch.sigmoid(logits).cpu().numpy()[0]\n\n                    y_pred.append(probs)\n\n        y_pred = np.concatenate(y_pred, axis=1).T\n        y_true = np.concatenate(ys_valid, axis=0)\n\n        score = metrics.roc_auc_score(y_true, y_pred)\n\n        print('[Epoch {}/{}] [Score: {}]'.format(epoch+1, nepochs, score))\n\n        if score > best_score:\n            best_score = score\n            best_state_dict = copy.deepcopy(model.state_dict())\n\nmodel.load_state_dict(best_state_dict)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"e9f34d5e-adf9-48bc-b939-f118c975c41f","cell_type":"code","source":"import matplotlib.pyplot as plt\n\ndef plot_roc(y_true, y_pred):\n    fig, axs = plt.subplots(3, 2, figsize=(15, 13))\n\n    for i, label in enumerate(labels):\n        fpr, tpr, _ = metrics.roc_curve(y_true[i], y_pred[i])\n        ax = axs[i//2, i%2]\n        ax.plot(fpr, tpr)\n        ax.set_title(label + ' ROC')\n        ax.plot([0, 1], [0, 1], 'k--')\n\n    plt.show()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"3051c6ab-0f15-4977-8dee-96b73cbf1085","cell_type":"code","source":"model.eval()\n\ny_pred = []\n\nsize = 10000\n\nfor eeg_batch, _ in tqdm(train_dataloader_):\n    for idx in range((eeg_batch.shape[-1] + size - 1) // size):\n        with torch.no_grad():\n            eeg_batch_ = eeg_batch[:, :, idx*size: (idx+1)*size].to(device)\n\n            logits = model(eeg_batch_)\n            probs = torch.sigmoid(logits).cpu().numpy()[0]\n\n            y_pred.append(probs)\n\ny_pred = np.concatenate(y_pred, axis=1).T\ny_true = np.concatenate(ys_train, axis=0)\n\nplot_roc(y_true.T, y_pred.T)\n\nprint('roc auc: ', metrics.roc_auc_score(y_true, y_pred))","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"771ea9e7-6e91-4e3a-ba27-6d863e76ac69","cell_type":"code","source":"model.eval()\n\ny_pred = []\n\nsize = 10000\n\nfor eeg_batch, _ in tqdm(valid_dataloader):\n    for idx in range((eeg_batch.shape[-1] + size - 1) // size):\n        with torch.no_grad():\n            eeg_batch_ = eeg_batch[:, :, idx*size: (idx+1)*size].to(device)\n\n            logits = model(eeg_batch_)\n            probs = torch.sigmoid(logits).cpu().numpy()[0]\n\n            y_pred.append(probs)\n\ny_pred = np.concatenate(y_pred, axis=1).T\ny_true = np.concatenate(ys_valid, axis=0)\n\nplot_roc(y_true.T, y_pred.T)\n\nprint('roc auc: ', metrics.roc_auc_score(y_true, y_pred))","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"89786555-6bc6-40f2-8d0a-ffc672005602","cell_type":"code","source":"import pandas as pd\nfrom tqdm import tqdm\n\nxs_test = []\nlengths = {}\n\ntestdir = Path('test')\n\nFNAME = 'subj{}_series{}_{}.csv'\n\nfor subj in range(1, 13):\n    for series in [9, 10]:\n        datapath = testdir / FNAME.format(subj, series, 'data')\n\n        x = pd.read_csv(datapath)\n        x = x.iloc[:,1:].values\n\n        xs_test.append(x.astype(np.float32))\n        lengths['{}_{}'.format(subj, series)] = xs_test[-1].shape[0]","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"678ab28d-fa62-42d8-b9e4-c80569b3de25","cell_type":"code","source":"class EEGDatasetTest(Dataset):\n    def __init__(self, x):\n        self.x = x\n\n    def __getitem__(self, idx):\n        eeg = self.x[idx]\n\n        return eeg.T\n\n    def __len__(self):\n        return len(self.x)\n\ndataset = EEGDatasetTest(xs_test)\ntest_dataloader = DataLoader(dataset, batch_size=1, num_workers=3, shuffle=False)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"188242f0-9161-4a71-b17d-c566ec4ab462","cell_type":"code","source":"model.eval()\n\ny_pred = []\n\nsize = 10000\n\nfor eeg_batch in tqdm(test_dataloader):\n    for idx in range((eeg_batch.shape[-1] + size - 1) // size):\n        with torch.no_grad():\n            eeg_batch_ = eeg_batch[:, :, idx*size: (idx+1)*size].to(device)\n\n            logits = model(eeg_batch_)\n            probs = torch.sigmoid(logits).cpu().numpy()[0]\n\n            y_pred.append(probs)\n\ny_pred = np.concatenate(y_pred, axis=1).T","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"5851b54f-3791-439b-8d98-aa1f44e9ea99","cell_type":"code","source":"submission = pd.DataFrame(y_pred, index=['subj{}_series{}_{}'.format(sbj, i, j) for sbj in range(1, 13) for i in [9, 10] for j in range(lengths['{}_{}'.format(sbj, i)])], columns=labels)\nsubmission.to_csv('Submission.csv', index_label='id', float_format='%.3f')\n\nsubmission.tail()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"06d2ecbd-d359-48f2-b8f7-d8add2795835","cell_type":"code","source":"!head Submission.csv","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"id":"fd038563-254a-4547-8e51-43774a2473b2","cell_type":"code","source":"!head sample_submission.csv","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}