{"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":"markdown","source":"Training script written in PyTorch which can be used to train BERT HuggingFace models based on PyTorch.\n\nAlso, uses wandbai to track the training.","metadata":{}},{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\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":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-05-14T16:27:58.290366Z","iopub.execute_input":"2022-05-14T16:27:58.291231Z","iopub.status.idle":"2022-05-14T16:28:48.508725Z","shell.execute_reply.started":"2022-05-14T16:27:58.291187Z","shell.execute_reply":"2022-05-14T16:28:48.507518Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!python --version","metadata":{"execution":{"iopub.status.busy":"2022-05-14T16:28:48.510932Z","iopub.execute_input":"2022-05-14T16:28:48.511301Z","iopub.status.idle":"2022-05-14T16:28:49.279Z","shell.execute_reply.started":"2022-05-14T16:28:48.511255Z","shell.execute_reply":"2022-05-14T16:28:49.277814Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# upgrade the transformers library\n!pip install --upgrade transformers","metadata":{"execution":{"iopub.status.busy":"2022-05-14T16:44:37.610458Z","iopub.execute_input":"2022-05-14T16:44:37.610792Z","iopub.status.idle":"2022-05-14T16:44:59.775471Z","shell.execute_reply.started":"2022-05-14T16:44:37.61075Z","shell.execute_reply":"2022-05-14T16:44:59.774224Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# All the imports\nimport platform\nimport numpy as np\nimport pandas as pd\nfrom tqdm.notebook import tqdm\nimport matplotlib.pyplot as plt\n\nimport gc\nimport os\nimport wandb\nimport json\nimport glob\nfrom scipy import sparse\nfrom pathlib import Path\n\nimport torch\nimport transformers\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom torch.cuda.amp import GradScaler, autocast\nfrom torch.utils.data import Dataset, DataLoader\n\nfrom sklearn.model_selection import GroupShuffleSplit\nfrom sklearn.metrics import mean_squared_error\nimport warnings\nwarnings.simplefilter('ignore')","metadata":{"execution":{"iopub.status.busy":"2022-05-14T16:47:56.394312Z","iopub.execute_input":"2022-05-14T16:47:56.394617Z","iopub.status.idle":"2022-05-14T16:48:07.377369Z","shell.execute_reply.started":"2022-05-14T16:47:56.394585Z","shell.execute_reply":"2022-05-14T16:48:07.376244Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}