{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import torch\nimport torch.nn as nn\nfrom torchvision import models\nfrom torchvision import transforms\n\nfrom zipfile import ZipFile","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-27T13:03:41.434241Z","iopub.execute_input":"2022-07-27T13:03:41.434692Z","iopub.status.idle":"2022-07-27T13:03:43.561731Z","shell.execute_reply.started":"2022-07-27T13:03:41.434594Z","shell.execute_reply":"2022-07-27T13:03:43.560443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class RandomModel(nn.Module):\n    def __init__(self):\n        super().__init__()\n        \n    def forward(self, x):\n        return [torch.rand(64)]","metadata":{"execution":{"iopub.status.busy":"2022-07-27T13:03:43.564234Z","iopub.execute_input":"2022-07-27T13:03:43.565266Z","iopub.status.idle":"2022-07-27T13:03:43.571506Z","shell.execute_reply.started":"2022-07-27T13:03:43.565233Z","shell.execute_reply":"2022-07-27T13:03:43.570167Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = RandomModel()\nmodel.eval()\nsaved_model = torch.jit.script(model)\nsaved_model.save('saved_model.pt')","metadata":{"execution":{"iopub.status.busy":"2022-07-27T13:03:43.573155Z","iopub.execute_input":"2022-07-27T13:03:43.573472Z","iopub.status.idle":"2022-07-27T13:03:43.622758Z","shell.execute_reply.started":"2022-07-27T13:03:43.573444Z","shell.execute_reply":"2022-07-27T13:03:43.621439Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with ZipFile('submission.zip','w') as zip:           \n    zip.write('saved_model.pt', arcname='saved_model.pt')","metadata":{"execution":{"iopub.status.busy":"2022-07-27T13:04:03.954585Z","iopub.execute_input":"2022-07-27T13:04:03.954952Z","iopub.status.idle":"2022-07-27T13:04:03.961579Z","shell.execute_reply.started":"2022-07-27T13:04:03.954923Z","shell.execute_reply":"2022-07-27T13:04:03.960666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls -lh","metadata":{"execution":{"iopub.status.busy":"2022-07-27T13:04:04.839356Z","iopub.execute_input":"2022-07-27T13:04:04.840419Z","iopub.status.idle":"2022-07-27T13:04:05.607081Z","shell.execute_reply.started":"2022-07-27T13:04:04.840347Z","shell.execute_reply":"2022-07-27T13:04:05.605444Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}