{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# NPZ Data Structure","metadata":{}},{"cell_type":"code","source":"import os\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2023-08-31T13:58:42.483209Z","iopub.execute_input":"2023-08-31T13:58:42.483841Z","iopub.status.idle":"2023-08-31T13:58:42.490168Z","shell.execute_reply.started":"2023-08-31T13:58:42.483798Z","shell.execute_reply":"2023-08-31T13:58:42.488946Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"paths=[]\nfor dirname, _, filenames in os.walk('/kaggle/input/predict-ai-model-runtime/npz_all/npz'):\n    for filename in filenames:\n        paths+=[(os.path.join(dirname, filename))]","metadata":{"execution":{"iopub.status.busy":"2023-08-31T13:58:42.496816Z","iopub.execute_input":"2023-08-31T13:58:42.498243Z","iopub.status.idle":"2023-08-31T13:58:42.572201Z","shell.execute_reply.started":"2023-08-31T13:58:42.498189Z","shell.execute_reply":"2023-08-31T13:58:42.571105Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = np.load(paths[0])\narray_names = data.files\nprint(array_names)\nfor name in array_names:\n    print(name,data[name].shape)","metadata":{"execution":{"iopub.status.busy":"2023-08-31T13:58:42.574344Z","iopub.execute_input":"2023-08-31T13:58:42.574676Z","iopub.status.idle":"2023-08-31T13:58:42.586198Z","shell.execute_reply.started":"2023-08-31T13:58:42.574648Z","shell.execute_reply":"2023-08-31T13:58:42.585305Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img=np.array(data['node_feat'])\nplt.imshow(img)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-31T13:58:42.587750Z","iopub.execute_input":"2023-08-31T13:58:42.588586Z","iopub.status.idle":"2023-08-31T13:58:42.861975Z","shell.execute_reply.started":"2023-08-31T13:58:42.588553Z","shell.execute_reply":"2023-08-31T13:58:42.860717Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df=pd.DataFrame(columns=['path','6','7','8','-2','-1','array_names'],index=range(len(paths)))\nfor i,path in enumerate(paths):\n    df.loc[i,'path']=path\n    df.loc[i,'6']=path.split('/')[6]\n    df.loc[i,'7']=path.split('/')[7]\n    df.loc[i,'8']=path.split('/')[8]\n    df.loc[i,'-2']=path.split('/')[-2]#train/valid/test\n    df.loc[i,'-1']=path.split('/')[-1]#filename\n    data=np.load(path)\n    df.loc[i,'array_names']=data.files\ndisplay(df)","metadata":{"execution":{"iopub.status.busy":"2023-08-31T13:58:42.864768Z","iopub.execute_input":"2023-08-31T13:58:42.865193Z","iopub.status.idle":"2023-08-31T13:58:54.532482Z","shell.execute_reply.started":"2023-08-31T13:58:42.865158Z","shell.execute_reply":"2023-08-31T13:58:54.531356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[df['6']=='layout']['array_names'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-08-31T13:58:54.534047Z","iopub.execute_input":"2023-08-31T13:58:54.534739Z","iopub.status.idle":"2023-08-31T13:58:54.548204Z","shell.execute_reply.started":"2023-08-31T13:58:54.534702Z","shell.execute_reply":"2023-08-31T13:58:54.546943Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[df['6']=='tile']['array_names'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-08-31T13:58:54.549916Z","iopub.execute_input":"2023-08-31T13:58:54.550262Z","iopub.status.idle":"2023-08-31T13:58:54.576306Z","shell.execute_reply.started":"2023-08-31T13:58:54.550232Z","shell.execute_reply":"2023-08-31T13:58:54.574861Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]}],"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"}}