-
Notifications
You must be signed in to change notification settings - Fork 0
/
functional_API_sarcasm_classification_BERT_combined_2data
1 lines (1 loc) · 125 KB
/
functional_API_sarcasm_classification_BERT_combined_2data
1
{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"id":"bpBile8xPdIA"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":1,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":17261,"status":"ok","timestamp":1670618888898,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"wuq_C7s66FL8","outputId":"f8cb1c70-369d-46cb-8ef7-fa96982470ff"},"outputs":[{"output_type":"stream","name":"stdout","text":["Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n","Collecting transformers\n"," Downloading transformers-4.25.1-py3-none-any.whl (5.8 MB)\n","\u001b[K |████████████████████████████████| 5.8 MB 4.1 MB/s \n","\u001b[?25hCollecting huggingface-hub<1.0,>=0.10.0\n"," Downloading huggingface_hub-0.11.1-py3-none-any.whl (182 kB)\n","\u001b[K |████████████████████████████████| 182 kB 92.1 MB/s \n","\u001b[?25hRequirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.7/dist-packages (from transformers) (21.3)\n","Collecting tokenizers!=0.11.3,<0.14,>=0.11.1\n"," Downloading tokenizers-0.13.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.6 MB)\n","\u001b[K |████████████████████████████████| 7.6 MB 27.4 MB/s \n","\u001b[?25hRequirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.7/dist-packages (from transformers) (2022.6.2)\n","Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from transformers) (2.23.0)\n","Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.7/dist-packages (from transformers) (1.21.6)\n","Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.7/dist-packages (from transformers) (6.0)\n","Requirement already satisfied: filelock in /usr/local/lib/python3.7/dist-packages (from transformers) (3.8.0)\n","Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.7/dist-packages (from transformers) (4.13.0)\n","Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.7/dist-packages (from transformers) (4.64.1)\n","Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.7/dist-packages (from huggingface-hub<1.0,>=0.10.0->transformers) (4.1.1)\n","Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.7/dist-packages (from packaging>=20.0->transformers) (3.0.9)\n","Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata->transformers) (3.10.0)\n","Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->transformers) (1.24.3)\n","Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->transformers) (2.10)\n","Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->transformers) (3.0.4)\n","Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->transformers) (2022.9.24)\n","Installing collected packages: tokenizers, huggingface-hub, transformers\n","Successfully installed huggingface-hub-0.11.1 tokenizers-0.13.2 transformers-4.25.1\n","Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n","Collecting datasets\n"," Downloading datasets-2.7.1-py3-none-any.whl (451 kB)\n","\u001b[K |████████████████████████████████| 451 kB 4.3 MB/s \n","\u001b[?25hCollecting multiprocess\n"," Downloading multiprocess-0.70.14-py37-none-any.whl (115 kB)\n","\u001b[K |████████████████████████████████| 115 kB 64.9 MB/s \n","\u001b[?25hRequirement already satisfied: importlib-metadata in /usr/local/lib/python3.7/dist-packages (from datasets) (4.13.0)\n","Requirement already satisfied: tqdm>=4.62.1 in /usr/local/lib/python3.7/dist-packages (from datasets) (4.64.1)\n","Collecting responses<0.19\n"," Downloading responses-0.18.0-py3-none-any.whl (38 kB)\n","Requirement already satisfied: fsspec[http]>=2021.11.1 in /usr/local/lib/python3.7/dist-packages (from datasets) (2022.11.0)\n","Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.7/dist-packages (from datasets) (6.0)\n","Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.7/dist-packages (from datasets) (1.21.6)\n","Requirement already satisfied: dill<0.3.7 in /usr/local/lib/python3.7/dist-packages (from datasets) (0.3.6)\n","Requirement already satisfied: requests>=2.19.0 in /usr/local/lib/python3.7/dist-packages (from datasets) (2.23.0)\n","Requirement already satisfied: packaging in /usr/local/lib/python3.7/dist-packages (from datasets) (21.3)\n","Requirement already satisfied: pyarrow>=6.0.0 in /usr/local/lib/python3.7/dist-packages (from datasets) (9.0.0)\n","Requirement already satisfied: huggingface-hub<1.0.0,>=0.2.0 in /usr/local/lib/python3.7/dist-packages (from datasets) (0.11.1)\n","Collecting xxhash\n"," Downloading xxhash-3.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (212 kB)\n","\u001b[K |████████████████████████████████| 212 kB 72.2 MB/s \n","\u001b[?25hRequirement already satisfied: pandas in /usr/local/lib/python3.7/dist-packages (from datasets) (1.3.5)\n","Requirement already satisfied: aiohttp in /usr/local/lib/python3.7/dist-packages (from datasets) (3.8.3)\n","Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (1.8.1)\n","Requirement already satisfied: asynctest==0.13.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (0.13.0)\n","Requirement already satisfied: typing-extensions>=3.7.4 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (4.1.1)\n","Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (22.1.0)\n","Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (4.0.2)\n","Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (1.3.1)\n","Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (1.3.3)\n","Requirement already satisfied: charset-normalizer<3.0,>=2.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (2.1.1)\n","Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (6.0.2)\n","Requirement already satisfied: filelock in /usr/local/lib/python3.7/dist-packages (from huggingface-hub<1.0.0,>=0.2.0->datasets) (3.8.0)\n","Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.7/dist-packages (from packaging->datasets) (3.0.9)\n","Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests>=2.19.0->datasets) (1.24.3)\n","Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests>=2.19.0->datasets) (2022.9.24)\n","Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests>=2.19.0->datasets) (2.10)\n","Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests>=2.19.0->datasets) (3.0.4)\n","Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1\n"," Downloading urllib3-1.25.11-py2.py3-none-any.whl (127 kB)\n","\u001b[K |████████████████████████████████| 127 kB 69.5 MB/s \n","\u001b[?25hRequirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata->datasets) (3.10.0)\n","Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas->datasets) (2.8.2)\n","Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.7/dist-packages (from pandas->datasets) (2022.6)\n","Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.7.3->pandas->datasets) (1.15.0)\n","Installing collected packages: urllib3, xxhash, responses, multiprocess, datasets\n"," Attempting uninstall: urllib3\n"," Found existing installation: urllib3 1.24.3\n"," Uninstalling urllib3-1.24.3:\n"," Successfully uninstalled urllib3-1.24.3\n","Successfully installed datasets-2.7.1 multiprocess-0.70.14 responses-0.18.0 urllib3-1.25.11 xxhash-3.1.0\n"]}],"source":["!pip install transformers\n","!pip install datasets"]},{"cell_type":"markdown","metadata":{"id":"7mWggpW86JSy"},"source":["# **Preprocessing data**"]},{"cell_type":"code","execution_count":2,"metadata":{"executionInfo":{"elapsed":3826,"status":"ok","timestamp":1670618892720,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"Znr33uHB6FOp"},"outputs":[],"source":["import tensorflow as tf\n","import numpy as np\n","import sklearn\n","from sklearn import metrics\n","import transformers\n","from transformers import AutoTokenizer, TFAutoModelForSequenceClassification\n","import json\n","import matplotlib.pyplot as plt\n","import random\n","import seaborn as sn\n","import pandas as pd\n","import re\n","from sklearn.model_selection import train_test_split\n","import tokenizers\n","from datasets import load_dataset\n","from datasets import Dataset\n","\n","import json\n","import os \n","import sklearn\n","import seaborn as sbs\n","import sklearn.naive_bayes \n","import sklearn.model_selection\n","import sklearn.metrics\n","import pandas as pd"]},{"cell_type":"code","execution_count":3,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":17964,"status":"ok","timestamp":1670618910681,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"E58m1doU6FRI","outputId":"c8d74779-fb8b-4a15-fa2e-b750ecd18605"},"outputs":[{"output_type":"stream","name":"stdout","text":["(1010826, 10)\n"]}],"source":["\n","def load_json(jfile):\n"," data = []\n"," with open(jfile) as f:\n"," for line in f.readlines():\n"," j = json.loads(line)\n"," url, headline, sarcastic = j['article_link'], j['headline'], j['is_sarcastic']\n"," data.append([url, headline, sarcastic])\n"," return pd.DataFrame(data, columns=['article_link', 'headline', 'is_sarcastic'])\n","\n","\n","def load_data_reddit(path):\n"," sarcasm_data = pd.read_csv(path)\n"," print(sarcasm_data.shape)\n"," # sarcasm_data.head()\n"," sarcasm_data.drop(['author', 'subreddit', 'score', 'ups', 'downs', 'date', 'created_utc', 'parent_comment'], axis=1, inplace=True)\n"," # remove empty rows\n"," sarcasm_data.dropna(inplace=True)\n"," # sarcasm_data.head()\n","\n"," mispell_dict = {\"ain't\": \"is not\", \"cannot\": \"can not\", \"aren't\": \"are not\", \"can't\": \"can not\", \"'cause\": \"because\", \"could've\": \"could have\", \"couldn't\": \"could not\", \"didn't\": \"did not\",\n"," \"doesn't\": \"does not\",\n"," \"don't\": \"do not\", \"hadn't\": \"had not\", \"hasn't\": \"has not\", \"haven't\": \"have not\", \"he'd\": \"he would\", \"he'll\": \"he will\", \"he's\": \"he is\", \"how'd\": \"how did\",\n"," \"how'd'y\": \"how do you\", \"how'll\": \"how will\", \"how's\": \"how is\", \"I'd\": \"I would\", \"I'd've\": \"I would have\", \"I'll\": \"I will\", \"I'll've\": \"I will have\", \"I'm\": \"I am\",\n"," \"I've\": \"I have\", \"i'd\": \"i would\", \"i'd've\": \"i would have\", \"i'll\": \"i will\", \"i'll've\": \"i will have\", \"i'm\": \"i am\", \"i've\": \"i have\", \"isn't\": \"is not\", \"it'd\": \"it would\",\n"," \"it'd've\": \"it would have\", \"it'll\": \"it will\", \"it'll've\": \"it will have\", \"it's\": \"it is\", \"let's\": \"let us\", \"ma'am\": \"madam\", \"mayn't\": \"may not\", \"might've\": \"might have\",\n"," \"mightn't\": \"might not\", \"mightn't've\": \"might not have\", \"must've\": \"must have\", \"mustn't\": \"must not\", \"mustn't've\": \"must not have\", \"needn't\": \"need not\",\n"," \"needn't've\": \"need not have\", \"o'clock\": \"of the clock\", \"oughtn't\": \"ought not\", \"oughtn't've\": \"ought not have\", \"shan't\": \"shall not\", \"sha'n't\": \"shall not\",\n"," \"shan't've\": \"shall not have\", \"she'd\": \"she would\", \"she'd've\": \"she would have\", \"she'll\": \"she will\", \"she'll've\": \"she will have\", \"she's\": \"she is\",\n"," \"should've\": \"should have\", \"shouldn't\": \"should not\", \"shouldn't've\": \"should not have\", \"so've\": \"so have\", \"so's\": \"so as\", \"this's\": \"this is\", \"that'd\": \"that would\",\n"," \"that'd've\": \"that would have\", \"that's\": \"that is\", \"there'd\": \"there would\", \"there'd've\": \"there would have\", \"there's\": \"there is\", \"here's\": \"here is\", \"they'd\": \"they would\",\n"," \"they'd've\": \"they would have\", \"they'll\": \"they will\", \"they'll've\": \"they will have\", \"they're\": \"they are\", \"they've\": \"they have\", \"to've\": \"to have\", \"wasn't\": \"was not\",\n"," \"we'd\": \"we would\", \"we'd've\": \"we would have\", \"we'll\": \"we will\", \"we'll've\": \"we will have\", \"we're\": \"we are\", \"we've\": \"we have\", \"weren't\": \"were not\",\n"," \"what'll\": \"what will\", \"what'll've\": \"what will have\", \"what're\": \"what are\", \"what's\": \"what is\", \"what've\": \"what have\", \"when's\": \"when is\", \"when've\": \"when have\",\n"," \"where'd\": \"where did\", \"where's\": \"where is\", \"where've\": \"where have\", \"who'll\": \"who will\", \"who'll've\": \"who will have\", \"who's\": \"who is\", \"who've\": \"who have\",\n"," \"why's\": \"why is\", \"why've\": \"why have\", \"will've\": \"will have\", \"won't\": \"will not\", \"wont\": \"will not\", \"won't've\": \"will not have\", \"would've\": \"would have\",\n"," \"wouldn't\": \"would not\",\n"," \"wouldn't've\": \"would not have\", \"y'all\": \"you all\", \"y'all'd\": \"you all would\", \"y'all'd've\": \"you all would have\", \"y'all're\": \"you all are\", \"y'all've\": \"you all have\",\n"," \"you'd\": \"you would\", \"you'd've\": \"you would have\", \"you'll\": \"you will\", \"you'll've\": \"you will have\", \"you're\": \"you are\", \"you've\": \"you have\", 'colour': 'color',\n"," 'centre': 'center', 'favourite': 'favorite', 'travelling': 'traveling', 'counselling': 'counseling', 'theatre': 'theater', 'cancelled': 'canceled', 'labour': 'labor',\n"," 'organisation': 'organization', 'wwii': 'world war 2', 'citicise': 'criticize', 'youtu ': 'youtube ', 'Qoura': 'Quora', 'sallary': 'salary', 'Whta': 'What',\n"," 'narcisist': 'narcissist', 'howdo': 'how do', 'whatare': 'what are', 'howcan': 'how can', 'howmuch': 'how much', 'howmany': 'how many', 'whydo': 'why do', 'doI': 'do I',\n"," 'theBest': 'the best', 'howdoes': 'how does', 'Etherium': 'Ethereum',\n"," 'narcissit': 'narcissist', 'bigdata': 'big data', '2k17': '2017', '2k18': '2018', 'qouta': 'quota', 'exboyfriend': 'ex boyfriend', 'airhostess': 'air hostess', \"whst\": 'what',\n"," 'watsapp': 'whatsapp', 'demonitisation': 'demonetization', 'demonitization': 'demonetization', 'demonetisation': 'demonetization'}\n","\n"," mispell_dict = {k.lower(): v.lower() for k, v in mispell_dict.items()}\n","\n"," def preprocessing_reddit_text(s):\n"," # making our string lowercase & removing extra spaces\n"," s = str(s).lower().strip()\n"," \n"," # remove contractions.\n"," s = \" \".join([mispell_dict[word] if word in mispell_dict.keys() else word for word in s.split()])\n"," \n"," # removing \\n\n"," s = re.sub('\\n', '', s)\n"," \n"," # put spaces before & after punctuations to make words seprate. Like \"king?\" to \"king\", \"?\".\n"," s = re.sub(r\"([?!,+=—&%\\'\\\";:¿।।।|\\(\\){}\\[\\]//])\", r\" \\1 \", s)\n"," \n"," # Remove more than 2 continues spaces with 1 space.\n"," s = re.sub('[ ]{2,}', ' ', s).strip()\n"," \n"," return s\n","\n"," # apply preprocessing_text function\n"," sarcasm_data['comment'] = sarcasm_data['comment'].apply(preprocessing_reddit_text)\n"," # sarcasm_data.head()\n","\n"," sarcasm_data = sarcasm_data.dropna()\n","\n"," sarcasm_data = sarcasm_data.reset_index(drop=True)\n"," data = sarcasm_data.drop([\"label\"], axis = 1)\n"," label = sarcasm_data.drop([\"comment\"], axis = 1)\n","\n"," return data, label\n","\n","\n","def load_data_headline(path1, path2):\n"," df = load_json(path1)\n"," df2 = load_json(path2)\n"," df.is_sarcastic.value_counts(normalize=True), df.is_sarcastic.value_counts()\n","\n"," frames = [df, df2] \n"," combine_df = pd.concat(frames)\n","\n"," combine_df.drop(['article_link'], axis=1, inplace=True)\n"," combine_df.dropna(inplace=True)\n"," \n"," mispell_dict = {\"ain't\": \"is not\", \"cannot\": \"can not\", \"aren't\": \"are not\", \"can't\": \"can not\", \"'cause\": \"because\", \"could've\": \"could have\", \"couldn't\": \"could not\", \"didn't\": \"did not\",\n"," \"doesn't\": \"does not\",\n"," \"don't\": \"do not\", \"hadn't\": \"had not\", \"hasn't\": \"has not\", \"haven't\": \"have not\", \"he'd\": \"he would\", \"he'll\": \"he will\", \"he's\": \"he is\", \"how'd\": \"how did\",\n"," \"how'd'y\": \"how do you\", \"how'll\": \"how will\", \"how's\": \"how is\", \"I'd\": \"I would\", \"I'd've\": \"I would have\", \"I'll\": \"I will\", \"I'll've\": \"I will have\", \"I'm\": \"I am\",\n"," \"I've\": \"I have\", \"i'd\": \"i would\", \"i'd've\": \"i would have\", \"i'll\": \"i will\", \"i'll've\": \"i will have\", \"i'm\": \"i am\", \"i've\": \"i have\", \"isn't\": \"is not\", \"it'd\": \"it would\",\n"," \"it'd've\": \"it would have\", \"it'll\": \"it will\", \"it'll've\": \"it will have\", \"it's\": \"it is\", \"let's\": \"let us\", \"ma'am\": \"madam\", \"mayn't\": \"may not\", \"might've\": \"might have\",\n"," \"mightn't\": \"might not\", \"mightn't've\": \"might not have\", \"must've\": \"must have\", \"mustn't\": \"must not\", \"mustn't've\": \"must not have\", \"needn't\": \"need not\",\n"," \"needn't've\": \"need not have\", \"o'clock\": \"of the clock\", \"oughtn't\": \"ought not\", \"oughtn't've\": \"ought not have\", \"shan't\": \"shall not\", \"sha'n't\": \"shall not\",\n"," \"shan't've\": \"shall not have\", \"she'd\": \"she would\", \"she'd've\": \"she would have\", \"she'll\": \"she will\", \"she'll've\": \"she will have\", \"she's\": \"she is\",\n"," \"should've\": \"should have\", \"shouldn't\": \"should not\", \"shouldn't've\": \"should not have\", \"so've\": \"so have\", \"so's\": \"so as\", \"this's\": \"this is\", \"that'd\": \"that would\",\n"," \"that'd've\": \"that would have\", \"that's\": \"that is\", \"there'd\": \"there would\", \"there'd've\": \"there would have\", \"there's\": \"there is\", \"here's\": \"here is\", \"they'd\": \"they would\",\n"," \"they'd've\": \"they would have\", \"they'll\": \"they will\", \"they'll've\": \"they will have\", \"they're\": \"they are\", \"they've\": \"they have\", \"to've\": \"to have\", \"wasn't\": \"was not\",\n"," \"we'd\": \"we would\", \"we'd've\": \"we would have\", \"we'll\": \"we will\", \"we'll've\": \"we will have\", \"we're\": \"we are\", \"we've\": \"we have\", \"weren't\": \"were not\",\n"," \"what'll\": \"what will\", \"what'll've\": \"what will have\", \"what're\": \"what are\", \"what's\": \"what is\", \"what've\": \"what have\", \"when's\": \"when is\", \"when've\": \"when have\",\n"," \"where'd\": \"where did\", \"where's\": \"where is\", \"where've\": \"where have\", \"who'll\": \"who will\", \"who'll've\": \"who will have\", \"who's\": \"who is\", \"who've\": \"who have\",\n"," \"why's\": \"why is\", \"why've\": \"why have\", \"will've\": \"will have\", \"won't\": \"will not\", \"wont\": \"will not\", \"won't've\": \"will not have\", \"would've\": \"would have\",\n"," \"wouldn't\": \"would not\",\n"," \"wouldn't've\": \"would not have\", \"y'all\": \"you all\", \"y'all'd\": \"you all would\", \"y'all'd've\": \"you all would have\", \"y'all're\": \"you all are\", \"y'all've\": \"you all have\",\n"," \"you'd\": \"you would\", \"you'd've\": \"you would have\", \"you'll\": \"you will\", \"you'll've\": \"you will have\", \"you're\": \"you are\", \"you've\": \"you have\", 'colour': 'color',\n"," 'centre': 'center', 'favourite': 'favorite', 'travelling': 'traveling', 'counselling': 'counseling', 'theatre': 'theater', 'cancelled': 'canceled', 'labour': 'labor',\n"," 'organisation': 'organization', 'wwii': 'world war 2', 'citicise': 'criticize', 'youtu ': 'youtube ', 'Qoura': 'Quora', 'sallary': 'salary', 'Whta': 'What',\n"," 'narcisist': 'narcissist', 'howdo': 'how do', 'whatare': 'what are', 'howcan': 'how can', 'howmuch': 'how much', 'howmany': 'how many', 'whydo': 'why do', 'doI': 'do I',\n"," 'theBest': 'the best', 'howdoes': 'how does', 'Etherium': 'Ethereum',\n"," 'narcissit': 'narcissist', 'bigdata': 'big data', '2k17': '2017', '2k18': '2018', 'qouta': 'quota', 'exboyfriend': 'ex boyfriend', 'airhostess': 'air hostess', \"whst\": 'what',\n"," 'watsapp': 'whatsapp', 'demonitisation': 'demonetization', 'demonitization': 'demonetization', 'demonetisation': 'demonetization'}\n"," \n"," mispell_dict = {k.lower(): v.lower() for k, v in mispell_dict.items()}\n","\n"," def preprocessing_headline_text(s):\n"," # making our string lowercase & removing extra spaces\n"," s = str(s).lower().strip()\n"," \n"," # remove contractions.\n"," s = \" \".join([mispell_dict[word] if word in mispell_dict.keys() else word for word in s.split()])\n"," \n"," # removing \\n\n"," s = re.sub('\\n', '', s)\n"," \n"," # put spaces before & after punctuations to make words seprate. Like \"king?\" to \"king\", \"?\".\n"," s = re.sub(r\"([?!,+=—&%\\'\\\";:¿।।।|\\(\\){}\\[\\]//])\", r\" \\1 \", s)\n"," \n"," # Remove more than 2 continues spaces with 1 space.\n"," s = re.sub('[ ]{2,}', ' ', s).strip()\n"," \n"," return s\n","\n"," # apply preprocessing_text function\n"," combine_df['headline'] = combine_df['headline'].apply(preprocessing_headline_text)\n"," # sarcasm_data.head()\n","\n"," combine_df = combine_df.dropna()\n","\n"," combine_df = combine_df.reset_index(drop=True)\n"," data = combine_df.drop([\"is_sarcastic\"], axis = 1)\n"," label = combine_df.drop([\"headline\"], axis = 1)\n"," \n"," return data, label\n"," \n","\n","reddit_path = \"/content/drive/MyDrive/thesis_datasets/train-balanced-sarcasm.csv\"\n","json_1_headline = '/content/drive/MyDrive/thesis_datasets/Sarcasm_Headlines_Dataset.json'\n","json_2_headline = '/content/drive/MyDrive/thesis_datasets/Sarcasm_Headlines_Dataset_v2.json'\n","\n","reddit_data, reddit_label = load_data_reddit(reddit_path)\n","headline_data, headline_label = load_data_headline(json_1_headline, json_2_headline)\n"]},{"cell_type":"markdown","metadata":{"id":"nSxV6ZJNJeM2"},"source":["**splitting the data**"]},{"cell_type":"code","execution_count":4,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":10,"status":"ok","timestamp":1670618910681,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"pxBHEw-s6FTa","outputId":"56e33d25-22df-4147-b5b4-2a027f8f9a53"},"outputs":[{"output_type":"stream","name":"stdout","text":["(1010773, 1)\n","(55328, 1)\n","(1010773, 1)\n","(55328, 1)\n"]}],"source":["print(reddit_data.shape)\n","print(headline_data.shape)\n","print(reddit_label.shape)\n","print(headline_label.shape)"]},{"cell_type":"code","execution_count":5,"metadata":{"executionInfo":{"elapsed":555,"status":"ok","timestamp":1670618911228,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"uRyh6mbuH-7J"},"outputs":[],"source":["train_text, val_text, train_labels, val_labels = train_test_split(reddit_data, reddit_label, test_size=0.1)"]},{"cell_type":"code","execution_count":6,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":3,"status":"ok","timestamp":1670618911229,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"XCZauik0EJpE","outputId":"6a4cb016-ca23-485e-a6f1-1357ca94b516"},"outputs":[{"output_type":"execute_result","data":{"text/plain":["numpy.ndarray"]},"metadata":{},"execution_count":6}],"source":["y_train = train_labels[\"label\"].to_numpy()\n","y_test = val_labels[\"label\"].to_numpy()\n","type(y_train)"]},{"cell_type":"markdown","metadata":{"id":"zOztdCrUJhL6"},"source":["**Tokenizing the data**"]},{"cell_type":"code","execution_count":7,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":113,"referenced_widgets":["c6e857e1358a44e3be91f434cf7cd993","421edeb2726f47658501a2417ac85e46","a27f53987d194560b2fb84c3f17b1189","d79255132ec7431aa8a03a4b84b26c7a","b85557703f254028859a811215da5770","f09e7ab52c2142d59301a43df16bd31d","f6fbad0807474909ba2fa52e08aec210","1eea61660258492da7a5611c1ae3e0f7","a95a611817d1438b8bb0d9cdd14db8db","eac91592f7814611aca7fbfb6ea052c0","d6f6d000d0fb441bb918480cae45e801","519dff3adfaf484facee9a183d95f7c4","ac9c43816bb142c2b287e5916b1d6d6d","9cb110f84f6c433ba5837935c34f6da3","0057990f4b514d1abd2ddfb7ebd07d5c","2c4e605e5bc8477cb6c85e3b8ba95ce1","bb997f736cfb43f2a51caa1413ebc93d","378b7979ff604b8d87c1349d562c2722","8ebed8d7fd6c479788e5c143a62b5101","12df3bb664d74ca6964c9a1a0cca0692","b700d222675349289ac1d476f42bd5cd","f9efb91d6e83405fb0100f0f223c3c27","6e754175b534438a8044a4e66db90b79","7feacac800204bfabbc9eff6db54c5d7","efe39c5db99b45239a8317d80f217472","e675fcdd75af4b54b297469ac089ab4f","fed090b513b74c50b4d1b6dabacc1a7d","d297a9d6d38246fd8664053188fe3ce1","d3e2f8d174ee4194a4b578e12c34bca8","21933542ae724aec8147e11a10fa6d26","4a6ecf68478545d4a51488c35e992207","3d7fb3791b324a8093bf05fc830ad3a9","bf08d49674e6430c8d8ef3991ffddab5"]},"executionInfo":{"elapsed":8705,"status":"ok","timestamp":1670618919932,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"uKTMExz9H-9H","outputId":"746b105c-4a07-4be8-c8fb-eed3ced61d2a"},"outputs":[{"output_type":"display_data","data":{"text/plain":["Downloading: 0%| | 0.00/232k [00:00<?, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"c6e857e1358a44e3be91f434cf7cd993"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["Downloading: 0%| | 0.00/28.0 [00:00<?, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"519dff3adfaf484facee9a183d95f7c4"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":["Downloading: 0%| | 0.00/570 [00:00<?, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"6e754175b534438a8044a4e66db90b79"}},"metadata":{}}],"source":["import tensorflow as tf\n","from transformers import BertTokenizer, TFBertModel\n","tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')\n","\n","train_dd = list(train_text[\"comment\"])\n","val_dd = list(val_text[\"comment\"])\n","# train_label = list(train_labels[\"label\"])\n","# val_label = list(val_labels[\"label\"])\n","\n","# train_encodings = tokenizer(train_dd, padding=\"max_length\", truncation=True, max_length = 100, return_tensors='tf')\n","# val_encodings = tokenizer(val_dd, padding=\"max_length\", truncation=True, max_length = 100, return_tensors='tf')\n","\n","# train_dataset = tf.data.Dataset.from_tensor_slices((\n","# dict(train_encodings),\n","# train_label\n","# ))\n","\n","# val_dataset = tf.data.Dataset.from_tensor_slices((\n","# dict(val_encodings),\n","# val_label\n","# ))"]},{"cell_type":"markdown","metadata":{"id":"ivQtz3j3KkES"},"source":["**Modelling Roberta**"]},{"cell_type":"code","execution_count":8,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":156,"referenced_widgets":["dbe9caa5970d4ed9ac389aed5d43fb60","bcb471593e114e7ab9e66d22ef4eac29","ce49422e870a4df2a24476f40aa5ce4d","eed740200b854d40bb1ffcf7952de707","875fad684f4046c1a366fa7572d82b8b","3673d748a55646b19976bee1f566b990","b3da0c4ae7394f8b9be2c5c8dcaff730","2d5f691e190045c08532f189caefbfa2","43f682f069284572989a48251e9c1a63","f7f2c34505f34cb78f9fe38428d320e5","08f109590bfa4e9c83c499a309744a39"]},"executionInfo":{"elapsed":18320,"status":"ok","timestamp":1670618938249,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"z3oAMVIFH_At","outputId":"980135d5-9d40-46ac-9c16-e3941f362ec9"},"outputs":[{"output_type":"display_data","data":{"text/plain":["Downloading: 0%| | 0.00/536M [00:00<?, ?B/s]"],"application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"dbe9caa5970d4ed9ac389aed5d43fb60"}},"metadata":{}},{"output_type":"stream","name":"stderr","text":["Some layers from the model checkpoint at bert-base-uncased were not used when initializing TFBertModel: ['mlm___cls', 'nsp___cls']\n","- This IS expected if you are initializing TFBertModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n","- This IS NOT expected if you are initializing TFBertModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n","All the layers of TFBertModel were initialized from the model checkpoint at bert-base-uncased.\n","If your task is similar to the task the model of the checkpoint was trained on, you can already use TFBertModel for predictions without further training.\n"]}],"source":["import tensorflow.keras as keras \n","\n","encoder = TFBertModel.from_pretrained(\"bert-base-uncased\")\n","\n","# encoder = TFDistilBertModel.from_pretrained(\"distilbert-base-uncased\")\n","\n","def bert_encode(texts, tokenizer, max_len=512):\n"," all_tokens = []\n"," all_masks = []\n"," all_segments = []\n"," \n"," for text in texts:\n"," text = tokenizer.tokenize(text)\n"," # text = tokenizer(text, padding=\"max_length\", truncation=True, max_length = max_len, return_tensors='tf')\n"," \n"," text = text[:max_len-2]\n"," input_sequence = [\"[CLS]\"] + text + [\"[SEP]\"]\n"," pad_len = max_len - len(input_sequence)\n"," \n"," tokens = tokenizer.convert_tokens_to_ids(input_sequence) + [0] * pad_len\n"," pad_masks = [1] * len(input_sequence) + [0] * pad_len\n"," segment_ids = [0] * max_len\n"," \n"," all_tokens.append(tokens)\n"," all_masks.append(pad_masks)\n"," all_segments.append(segment_ids)\n"," \n"," return np.array(all_tokens), np.array(all_masks), np.array(all_segments)\n","\n","\n","def build_model(bert_layer, max_len=512):\n","# def build_model(distilbert_layer, max_len=100):\n"," input_word_ids = tf.keras.Input(shape=(max_len,), dtype=tf.int32, name=\"input_word_ids\")\n"," input_mask = tf.keras.Input(shape=(max_len,), dtype=tf.int32, name=\"input_mask\")\n"," segment_ids = tf.keras.Input(shape=(max_len,), dtype=tf.int32, name=\"segment_ids\")\n"," \n"," bert_layer.trainable = False\n"," sequence_output = bert_layer([input_word_ids, input_mask, segment_ids])\n"," # clf_output = sequence_output[:, 0, :]\n"," clf_output = sequence_output[0]\n","\n","\n"," # pooled_output, sequence_output = bert_layer([input_word_ids, input_mask, segment_ids])\n"," # bert_layer = bert_layer\n"," # bert_layer.trainable = False\n"," # clf_output = bert_layer[:, 0, :]\n"," # clf_output = bert_layer[0]\n","\n"," net = tf.keras.layers.Bidirectional(keras.layers.GRU(246, return_sequences=True))(clf_output)\n"," net = tf.keras.layers.Dropout(0.3)(net)\n"," net = tf.keras.layers.Bidirectional(keras.layers.GRU(246, return_sequences=True))(net)\n"," net = tf.keras.layers.Dropout(0.2)(net)\n"," net = tf.keras.layers.Bidirectional(keras.layers.GRU(146))(net)\n"," net = tf.keras.layers.Dropout(0.3)(net)\n"," # net = tf.keras.layers.Conv1D(246, 1)(clf_output)\n"," # net = tf.keras.layers.Dropout(0.3)(net)\n"," # net = tf.keras.layers.Conv1D(128, 1)(net)\n"," # net = tf.keras.layers.Dropout(0.3)(net)\n"," # net = tf.keras.layers.Flatten()(net)\n"," # net = tf.keras.layers.GlobalMaxPool1D()(net)\n"," net = tf.keras.layers.Dense(124, activation='relu')(net)\n"," # net = tf.keras.layers.Dropout(0.2)(net)\n"," out = tf.keras.layers.Dense(2, activation='softmax')(net)\n"," \n"," model = tf.keras.models.Model(inputs=[input_word_ids, input_mask, segment_ids], outputs=out)\n"," # model = tf.keras.models.Model(inputs=input_word_ids, outputs=out)\n"," model.compile(tf.keras.optimizers.Adam(lr=5e-5), loss='sparse_categorical_crossentropy', metrics=['accuracy'])\n"," \n"," return model\n"]},{"cell_type":"code","execution_count":9,"metadata":{"executionInfo":{"elapsed":333046,"status":"ok","timestamp":1670619271287,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"koe0hq_aJvxa"},"outputs":[],"source":["max_len = 100\n","\n","X_train = bert_encode(train_dd, tokenizer, max_len=max_len)\n","X_val = bert_encode(val_dd, tokenizer, max_len=max_len)"]},{"cell_type":"code","execution_count":10,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":6170,"status":"ok","timestamp":1670619277455,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"QQ5YehpWJxNn","outputId":"87b614c7-ae92-4fba-93e6-dd3ea40a47f7"},"outputs":[{"output_type":"stream","name":"stdout","text":["Model: \"model\"\n","__________________________________________________________________________________________________\n"," Layer (type) Output Shape Param # Connected to \n","==================================================================================================\n"," input_word_ids (InputLayer) [(None, 100)] 0 [] \n"," \n"," input_mask (InputLayer) [(None, 100)] 0 [] \n"," \n"," segment_ids (InputLayer) [(None, 100)] 0 [] \n"," \n"," tf_bert_model (TFBertModel) TFBaseModelOutputWi 109482240 ['input_word_ids[0][0]', \n"," thPoolingAndCrossAt 'input_mask[0][0]', \n"," tentions(last_hidde 'segment_ids[0][0]'] \n"," n_state=(None, 100, \n"," 768), \n"," pooler_output=(Non \n"," e, 768), \n"," past_key_values=No \n"," ne, hidden_states=N \n"," one, attentions=Non \n"," e, cross_attentions \n"," =None) \n"," \n"," bidirectional (Bidirectional) (None, 100, 492) 1499616 ['tf_bert_model[0][0]'] \n"," \n"," dropout_37 (Dropout) (None, 100, 492) 0 ['bidirectional[0][0]'] \n"," \n"," bidirectional_1 (Bidirectional (None, 100, 492) 1092240 ['dropout_37[0][0]'] \n"," ) \n"," \n"," dropout_38 (Dropout) (None, 100, 492) 0 ['bidirectional_1[0][0]'] \n"," \n"," bidirectional_2 (Bidirectional (None, 292) 560640 ['dropout_38[0][0]'] \n"," ) \n"," \n"," dropout_39 (Dropout) (None, 292) 0 ['bidirectional_2[0][0]'] \n"," \n"," dense (Dense) (None, 124) 36332 ['dropout_39[0][0]'] \n"," \n"," dense_1 (Dense) (None, 2) 250 ['dense[0][0]'] \n"," \n","==================================================================================================\n","Total params: 112,671,318\n","Trainable params: 3,189,078\n","Non-trainable params: 109,482,240\n","__________________________________________________________________________________________________\n"]},{"output_type":"stream","name":"stderr","text":["/usr/local/lib/python3.7/dist-packages/keras/optimizers/optimizer_v2/adam.py:110: UserWarning: The `lr` argument is deprecated, use `learning_rate` instead.\n"," super(Adam, self).__init__(name, **kwargs)\n"]}],"source":["# build model\n","\n","model = build_model(encoder, max_len=max_len)\n","model.summary()"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"background_save":true,"base_uri":"https://localhost:8080/"},"id":"mTWO8X27J_Y8","outputId":"3d1c38f5-74e9-4652-fb48-c236b47c360b"},"outputs":[{"name":"stdout","output_type":"stream","text":["Epoch 1/10\n","28428/28428 [==============================] - ETA: 0s - loss: 0.5622 - accuracy: 0.7044\n","Epoch 1: val_accuracy improved from -inf to 0.72784, saving model to /content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/BERT/model_e10/model.h5\n","28428/28428 [==============================] - 2120s 74ms/step - loss: 0.5622 - accuracy: 0.7044 - val_loss: 0.5317 - val_accuracy: 0.7278\n","Epoch 2/10\n","28428/28428 [==============================] - ETA: 0s - loss: 0.5314 - accuracy: 0.7285\n","Epoch 2: val_accuracy improved from 0.72784 to 0.74042, saving model to /content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/BERT/model_e10/model.h5\n","28428/28428 [==============================] - 2093s 74ms/step - loss: 0.5314 - accuracy: 0.7285 - val_loss: 0.5156 - val_accuracy: 0.7404\n","Epoch 3/10\n","28428/28428 [==============================] - ETA: 0s - loss: 0.5156 - accuracy: 0.7399\n","Epoch 3: val_accuracy improved from 0.74042 to 0.74835, saving model to /content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/BERT/model_e10/model.h5\n","28428/28428 [==============================] - 2098s 74ms/step - loss: 0.5156 - accuracy: 0.7399 - val_loss: 0.5044 - val_accuracy: 0.7484\n","Epoch 4/10\n","28428/28428 [==============================] - ETA: 0s - loss: 0.5048 - accuracy: 0.7481\n","Epoch 4: val_accuracy improved from 0.74835 to 0.75239, saving model to /content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/BERT/model_e10/model.h5\n","28428/28428 [==============================] - 2090s 74ms/step - loss: 0.5048 - accuracy: 0.7481 - val_loss: 0.5010 - val_accuracy: 0.7524\n","Epoch 5/10\n","28428/28428 [==============================] - ETA: 0s - loss: 0.4963 - accuracy: 0.7541\n","Epoch 5: val_accuracy improved from 0.75239 to 0.75454, saving model to /content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/BERT/model_e10/model.h5\n","28428/28428 [==============================] - 2105s 74ms/step - loss: 0.4963 - accuracy: 0.7541 - val_loss: 0.4972 - val_accuracy: 0.7545\n","Epoch 6/10\n","28428/28428 [==============================] - ETA: 0s - loss: 0.4881 - accuracy: 0.7598\n","Epoch 6: val_accuracy improved from 0.75454 to 0.76177, saving model to /content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/BERT/model_e10/model.h5\n","28428/28428 [==============================] - 2106s 74ms/step - loss: 0.4881 - accuracy: 0.7598 - val_loss: 0.4882 - val_accuracy: 0.7618\n","Epoch 7/10\n","28428/28428 [==============================] - ETA: 0s - loss: 0.4806 - accuracy: 0.7647\n","Epoch 7: val_accuracy improved from 0.76177 to 0.76332, saving model to /content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/BERT/model_e10/model.h5\n","28428/28428 [==============================] - 2104s 74ms/step - loss: 0.4806 - accuracy: 0.7647 - val_loss: 0.4871 - val_accuracy: 0.7633\n","Epoch 8/10\n","28428/28428 [==============================] - ETA: 0s - loss: 0.4741 - accuracy: 0.7692\n","Epoch 8: val_accuracy improved from 0.76332 to 0.76475, saving model to /content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/BERT/model_e10/model.h5\n","28428/28428 [==============================] - 2082s 73ms/step - loss: 0.4741 - accuracy: 0.7692 - val_loss: 0.4874 - val_accuracy: 0.7647\n","Epoch 9/10\n","28428/28428 [==============================] - ETA: 0s - loss: 0.4677 - accuracy: 0.7737\n","Epoch 9: val_accuracy did not improve from 0.76475\n","28428/28428 [==============================] - 2086s 73ms/step - loss: 0.4677 - accuracy: 0.7737 - val_loss: 0.4852 - val_accuracy: 0.7645\n","Epoch 10/10\n","28428/28428 [==============================] - ETA: 0s - loss: 0.4615 - accuracy: 0.7771\n","Epoch 10: val_accuracy did not improve from 0.76475\n","28428/28428 [==============================] - 2099s 74ms/step - loss: 0.4615 - accuracy: 0.7771 - val_loss: 0.4851 - val_accuracy: 0.7643\n","CPU times: user 6h 25min 16s, sys: 54min 18s, total: 7h 19min 34s\n","Wall time: 5h 49min 46s\n"]}],"source":["# training\n","\n","%%time\n","checkpoint = tf.keras.callbacks.ModelCheckpoint('/content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/BERT/model_e10/model.h5', monitor='val_accuracy', save_best_only=True, verbose=1)\n","earlystopping = tf.keras.callbacks.EarlyStopping(monitor='val_accuracy', patience=3, verbose=1)\n","\n","train_history = model.fit(\n"," X_train, y_train,\n"," validation_data=(X_val, y_test),\n"," # validation_split=0.1,\n"," epochs=10,\n"," callbacks=[checkpoint, earlystopping],\n"," batch_size=32,\n"," verbose=1\n",")"]},{"cell_type":"markdown","metadata":{"id":"TKruNO5IaZkJ"},"source":["**Loading Model**"]},{"cell_type":"code","execution_count":11,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":728477,"status":"ok","timestamp":1670620008342,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"BY3tRwXMKG0e","outputId":"3951f6da-ed01-49f6-ee9e-17357ade39ab"},"outputs":[{"output_type":"stream","name":"stdout","text":["3159/3159 [==============================] - 722s 227ms/step\n","Validation accuracy: 0.7864322602346703\n","CPU times: user 4min 10s, sys: 44.2 s, total: 4min 54s\n","Wall time: 12min 10s\n"]}],"source":["%%time\n","model.load_weights('/content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/BERT/model_e10/model.h5')\n","y_preds = model.predict(X_val).round().astype(int).argmax(axis=-1)\n","print(\"Validation accuracy: \", sklearn.metrics.accuracy_score(y_test, y_preds))"]},{"cell_type":"code","source":["# Confusion matrix\n","\n","from sklearn.metrics import confusion_matrix\n","cm = confusion_matrix(y_test, y_preds)\n","cm"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"oK2LnS0KtohT","executionInfo":{"status":"ok","timestamp":1670620052756,"user_tz":-540,"elapsed":421,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"}},"outputId":"10f5e4f8-bbaf-49c3-a143-adf789a1e456"},"execution_count":12,"outputs":[{"output_type":"execute_result","data":{"text/plain":["array([[42112, 8515],\n"," [13072, 37379]])"]},"metadata":{},"execution_count":12}]},{"cell_type":"code","source":["from sklearn.metrics import classification_report\n","print(classification_report(y_test, y_preds, target_names = ['Not Sarcastic','Sarcastic']))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"hxBMr6b2tojm","executionInfo":{"status":"ok","timestamp":1670620053171,"user_tz":-540,"elapsed":2,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"}},"outputId":"dec824fa-dc0b-4f53-c6d5-40a053f0b728"},"execution_count":13,"outputs":[{"output_type":"stream","name":"stdout","text":[" precision recall f1-score support\n","\n","Not Sarcastic 0.76 0.83 0.80 50627\n"," Sarcastic 0.81 0.74 0.78 50451\n","\n"," accuracy 0.79 101078\n"," macro avg 0.79 0.79 0.79 101078\n"," weighted avg 0.79 0.79 0.79 101078\n","\n"]}]},{"cell_type":"code","source":["import seaborn as sns\n","\n","plt.figure(figsize = (15,10))\n","sns.heatmap(cm, cmap= \"Blues\", linecolor = 'black' , linewidth = 1 , annot = True, fmt='')\n","plt.xlabel(\"Predicted\")\n","plt.ylabel(\"Actual\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":623},"id":"lM8Lzfnhtolu","executionInfo":{"status":"ok","timestamp":1670620054452,"user_tz":-540,"elapsed":871,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"}},"outputId":"5f7d7eef-8dea-4673-c339-f8e3e8243f4c"},"execution_count":14,"outputs":[{"output_type":"execute_result","data":{"text/plain":["Text(114.0, 0.5, 'Actual')"]},"metadata":{},"execution_count":14},{"output_type":"display_data","data":{"text/plain":["<Figure size 1080x720 with 2 Axes>"],"image/png":"iVBORw0KGgoAAAANSUhEUgAAAzYAAAJNCAYAAADj3eD3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3debheVX0v8O8vCRBkkBkpaEXBAaiiIuJQ64gB9aJ1xFbRco3egvNV1NrihNVaax2oFhUBqyLOSNFIAQdQJCiIAnqJoAJFBkEUBCFh3T/OJj1Azs6JcE6y4PPpsx/ed+2197ve9/FJ88t3rbWrtRYAAICezVndAwAAALitFDYAAED3FDYAAED3FDYAAED3FDYAAED3FDYAAED35q3uAUylquxDDQDAjGut1eoew3Ss+6D9Z+3vx9ee/sEufpPJ1tjCJknm77zf6h4CQDeuO+PgJMm1N/h3IYDpWnet7v7+zhRMRQMAALq3Ric2AADAoGQSY/w6AABA9yQ2AADQg7IeaIzEBgAA6J7EBgAAemCNzSi/DgAA0D2JDQAA9MAam1ESGwAAoHsSGwAA6IE1NqP8OgAAQPckNgAA0ANrbEZJbAAAgO4pbAAAgO6ZigYAAD2wecAovw4AANA9iQ0AAPTA5gGjJDYAAED3JDYAANADa2xG+XUAAIDuSWwAAKAH1tiMktgAAADdk9gAAEAPrLEZ5dcBAAC6J7EBAIAeWGMzSmIDAAB0T2IDAAA9sMZmlF8HAADonsIGAAB6UHNm75jOcKrmVtXpVXXM8H7bqvpeVS2pqs9U1dpD+zrD+yXD+XtOuscbhvaf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V5HlD2x5JNr7dvhUAzACFDcCa66OZWD/zg6r6cZJ/z0TS/sUk5w7njkjy3Vte2Fq7LMnCJF+oqh8m+cxw6itJnn7T5gFJXp5kl2FzgrPzP7uzvSUThdFZmZiS9ssZ+o4AcLuo1trqHgMAAMBtIrEBAAC6p7ABAAC6p7ABAAC6p7ABAAC6p7ABAAC6p7ABAAC6p7ABAAC6p7ABAAC69/8Bv/YXdSOp9goAAAAASUVORK5CYII=\n"},"metadata":{"needs_background":"light"}}]},{"cell_type":"code","source":[],"metadata":{"id":"uQ1yWmsWtooZ"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":[],"metadata":{"id":"cXyav0zMtorM"},"execution_count":null,"outputs":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"-UYVfxz_KG37"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"se_lBORE8Nz2"},"outputs":[],"source":["# hugging face model save\n","\n","# text_classification_model.save_weights('/content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/distil_h5/weights.h5')"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":26021,"status":"ok","timestamp":1668608536910,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"SzQLw25r0GAX","outputId":"767acd61-e0fd-4d8a-f3e5-0ee037c2dd9c"},"outputs":[{"name":"stderr","output_type":"stream","text":["WARNING:tensorflow:Skipping full serialization of Keras layer <keras.layers.regularization.dropout.Dropout object at 0x7f01f63e3c50>, because it is not built.\n","WARNING:tensorflow:Skipping full serialization of Keras layer <keras.layers.regularization.dropout.Dropout object at 0x7f0207a45ad0>, because it is not built.\n","WARNING:tensorflow:Skipping full serialization of Keras layer <keras.layers.regularization.dropout.Dropout object at 0x7f02048f2b90>, because it is not built.\n","WARNING:tensorflow:Skipping full serialization of Keras layer <keras.layers.regularization.dropout.Dropout object at 0x7f02048e05d0>, because it is not built.\n","WARNING:tensorflow:Skipping full serialization of Keras layer <keras.layers.regularization.dropout.Dropout object at 0x7f02048c92d0>, because it is not built.\n","WARNING:tensorflow:Skipping full serialization of Keras layer <keras.layers.regularization.dropout.Dropout object at 0x7f0204a2ef50>, because it is not built.\n","WARNING:tensorflow:Skipping full serialization of Keras layer <keras.layers.rnn.bidirectional.Bidirectional object at 0x7f0207b35c10>, because it is not built.\n","WARNING:tensorflow:Skipping full serialization of Keras layer <keras.layers.rnn.gru.GRU object at 0x7f0207b35e50>, because it is not built.\n","WARNING:tensorflow:Skipping full serialization of Keras layer <keras.layers.rnn.gru.GRU object at 0x7f0207b3c7d0>, because it is not built.\n","WARNING:tensorflow:Skipping full serialization of Keras layer <keras.layers.rnn.gru.GRUCell object at 0x7f0207b35f10>, because it is not built.\n","WARNING:tensorflow:Skipping full serialization of Keras layer <keras.layers.rnn.gru.GRUCell object at 0x7f0207b3c950>, because it is not built.\n","WARNING:absl:Found untraced functions such as _jit_compiled_convolution_op, _jit_compiled_convolution_op, embeddings_layer_call_fn, embeddings_layer_call_and_return_conditional_losses, transformer_layer_call_fn while saving (showing 5 of 166). These functions will not be directly callable after loading.\n"]}],"source":["# Save the entire model\n","# text_classification_model.save('/content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/distilBert_model_e5/')\n","\n","# it will work\n","# model.save()"]},{"cell_type":"markdown","metadata":{"id":"3gzhQn7jhewL"},"source":["**Load model**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"d5gklw0Gk3Vq"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"0m9sG1eba4YA"},"outputs":[],"source":["# model = BertModel.from_pretrained(\"./test/saved_model/\")"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"4w3r6Ru2a4bK"},"outputs":[],"source":["from transformers import AutoModelForSequenceClassification\n","\n","path = \"/content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/distilbert/weights2\"\n","imported = tf.saved_model.load(path)\n","# model = AutoModelForSequenceClassification.from_pretrained(path)\n","\n","DEFAULT_FUNCTION_KEY = 'serving_default'\n","# loaded = tf.saved_model.load(saved_model_path)\n","inference_func = imported.signatures[DEFAULT_FUNCTION_KEY]"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":432},"executionInfo":{"elapsed":316,"status":"error","timestamp":1668759374517,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"ZTBbt5i5yab8","outputId":"b9fa0924-b6ca-4dbc-9f9c-505bc3228440"},"outputs":[{"ename":"TypeError","evalue":"ignored","output_type":"error","traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_impl\u001b[0;34m(self, args, kwargs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1615\u001b[0m return self._call_with_flat_signature(args, kwargs,\n\u001b[0;32m-> 1616\u001b[0;31m cancellation_manager)\n\u001b[0m\u001b[1;32m 1617\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_with_flat_signature\u001b[0;34m(self, args, kwargs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1639\u001b[0m raise TypeError(\n\u001b[0;32m-> 1640\u001b[0;31m \u001b[0;34mf\"{self._flat_signature_summary()} takes {self._num_positional_args} \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1641\u001b[0m f\"positional arguments, got {len(args)}.\")\n","\u001b[0;31mTypeError\u001b[0m: signature_wrapper(attention_mask, input_ids) takes 0 positional arguments, got 1.","\nDuring handling of the above exception, another exception occurred:\n","\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)","\u001b[0;32m<ipython-input-14-ba12eb67e017>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mbatch\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mval_dataset\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtake\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minference_func\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbatch\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1600\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mIf\u001b[0m \u001b[0mthe\u001b[0m \u001b[0marguments\u001b[0m \u001b[0mdo\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mmatch\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mfunction\u001b[0m\u001b[0;31m'\u001b[0m\u001b[0ms\u001b[0m \u001b[0msignature\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1601\u001b[0m \"\"\"\n\u001b[0;32m-> 1602\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_call_impl\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1603\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1604\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_call_impl\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcancellation_manager\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_impl\u001b[0;34m(self, args, kwargs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1616\u001b[0m cancellation_manager)\n\u001b[1;32m 1617\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1618\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mstructured_err\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1619\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1620\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_call_with_flat_signature\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcancellation_manager\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_impl\u001b[0;34m(self, args, kwargs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1610\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1611\u001b[0m return self._call_with_structured_signature(args, kwargs,\n\u001b[0;32m-> 1612\u001b[0;31m cancellation_manager)\n\u001b[0m\u001b[1;32m 1613\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mstructured_err\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1614\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_with_structured_signature\u001b[0;34m(self, args, kwargs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1687\u001b[0m args, kwargs, filtered_flat_args = (\n\u001b[1;32m 1688\u001b[0m self._function_spec.canonicalize_function_inputs(*args, **kwargs))\n\u001b[0;32m-> 1689\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_structured_signature_check_missing_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1690\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_structured_signature_check_unexpected_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1691\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_structured_signature_check_arg_types\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_structured_signature_check_missing_args\u001b[0;34m(self, args, kwargs)\u001b[0m\n\u001b[1;32m 1706\u001b[0m \u001b[0mmissing_arguments\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1707\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmissing_arguments\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1708\u001b[0;31m raise TypeError(f\"{self._structured_signature_summary()} missing \"\n\u001b[0m\u001b[1;32m 1709\u001b[0m \u001b[0;34m\"required arguments: \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1710\u001b[0m f\"{', '.join(sorted(missing_arguments))}.\")\n","\u001b[0;31mTypeError\u001b[0m: signature_wrapper(*, attention_mask, input_ids) missing required arguments: attention_mask, input_ids."]}],"source":["# predict_dataset = eval_dataset.map(lambda image, label: image)\n","\n","for batch in val_dataset.take(1):\n"," print(inference_func(batch))"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":2,"status":"ok","timestamp":1668759538400,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"X8a4b5WhzgAW","outputId":"2af0778b-c3f5-4653-d2b4-021f2df7a899"},"outputs":[{"name":"stdout","output_type":"stream","text":["({'input_ids': <tf.Tensor: shape=(100,), dtype=int32, numpy=\n","array([ 101, 2129, 8108, 2017, 10214, 2000, 2031, 3348, 2074,\n"," 2138, 1996, 2060, 2711, 2003, 1037, 2450, 1010, 2008,\n"," 2003, 3348, 2923, 102, 0, 0, 0, 0, 0,\n"," 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"," 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"," 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"," 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"," 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"," 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"," 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"," 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"," 0], dtype=int32)>, 'attention_mask': <tf.Tensor: shape=(100,), dtype=int32, numpy=\n","array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n"," 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"," 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"," 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n"," 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=int32)>}, <tf.Tensor: shape=(), dtype=int32, numpy=1>)\n"]}],"source":["for i in val_dataset.take(1):\n"," print(i)"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"2SZ-Gw-wyQyV"},"outputs":[],"source":["sDEFAULT_FUNCTION_KEY = 'serving_default'\n","loaded = tf.saved_model.load(saved_model_path)\n","inference_func = loaded.signatures[DEFAULT_FUNCTION_KEY]"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":432},"executionInfo":{"elapsed":333,"status":"error","timestamp":1668759568794,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"0R-5V4QhjnEx","outputId":"7ab225aa-3b2d-4ae7-a925-957c8d76de6e"},"outputs":[{"ename":"TypeError","evalue":"ignored","output_type":"error","traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_impl\u001b[0;34m(self, args, kwargs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1615\u001b[0m return self._call_with_flat_signature(args, kwargs,\n\u001b[0;32m-> 1616\u001b[0;31m cancellation_manager)\n\u001b[0m\u001b[1;32m 1617\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_with_flat_signature\u001b[0;34m(self, args, kwargs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1639\u001b[0m raise TypeError(\n\u001b[0;32m-> 1640\u001b[0;31m \u001b[0;34mf\"{self._flat_signature_summary()} takes {self._num_positional_args} \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1641\u001b[0m f\"positional arguments, got {len(args)}.\")\n","\u001b[0;31mTypeError\u001b[0m: signature_wrapper(attention_mask, input_ids) takes 0 positional arguments, got 1.","\nDuring handling of the above exception, another exception occurred:\n","\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)","\u001b[0;32m<ipython-input-22-c8cbb63bd6a1>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mff\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minference_func\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnext\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0miter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mval_dataset\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbatch\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m32\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnumpy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mff\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0margmax\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1600\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mIf\u001b[0m \u001b[0mthe\u001b[0m \u001b[0marguments\u001b[0m \u001b[0mdo\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mmatch\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mfunction\u001b[0m\u001b[0;31m'\u001b[0m\u001b[0ms\u001b[0m \u001b[0msignature\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1601\u001b[0m \"\"\"\n\u001b[0;32m-> 1602\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_call_impl\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1603\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1604\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_call_impl\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcancellation_manager\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_impl\u001b[0;34m(self, args, kwargs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1616\u001b[0m cancellation_manager)\n\u001b[1;32m 1617\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1618\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mstructured_err\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1619\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1620\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_call_with_flat_signature\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcancellation_manager\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_impl\u001b[0;34m(self, args, kwargs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1610\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1611\u001b[0m return self._call_with_structured_signature(args, kwargs,\n\u001b[0;32m-> 1612\u001b[0;31m cancellation_manager)\n\u001b[0m\u001b[1;32m 1613\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mstructured_err\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1614\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_with_structured_signature\u001b[0;34m(self, args, kwargs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1687\u001b[0m args, kwargs, filtered_flat_args = (\n\u001b[1;32m 1688\u001b[0m self._function_spec.canonicalize_function_inputs(*args, **kwargs))\n\u001b[0;32m-> 1689\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_structured_signature_check_missing_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1690\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_structured_signature_check_unexpected_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1691\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_structured_signature_check_arg_types\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_structured_signature_check_missing_args\u001b[0;34m(self, args, kwargs)\u001b[0m\n\u001b[1;32m 1706\u001b[0m \u001b[0mmissing_arguments\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1707\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmissing_arguments\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1708\u001b[0;31m raise TypeError(f\"{self._structured_signature_summary()} missing \"\n\u001b[0m\u001b[1;32m 1709\u001b[0m \u001b[0;34m\"required arguments: \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1710\u001b[0m f\"{', '.join(sorted(missing_arguments))}.\")\n","\u001b[0;31mTypeError\u001b[0m: signature_wrapper(*, attention_mask, input_ids) missing required arguments: attention_mask, input_ids."]}],"source":["ff = inference_func(next(iter(val_dataset.batch(32)))).numpy()\n","ff.argmax(axis=-1)"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":235},"executionInfo":{"elapsed":1508,"status":"error","timestamp":1668501055076,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"gp-NdK4oa4fm","outputId":"e5747139-46dd-4294-c734-cfe2c1b60f7f"},"outputs":[{"ename":"AttributeError","evalue":"ignored","output_type":"error","traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)","\u001b[0;32m<ipython-input-29-268ddd4147d9>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mimported\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpredict_on_batch\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnext\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0miter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mval_dataset\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbatch\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m16\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnumpy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;31m# ff = new_model(next(iter(val_dataset.batch(16)))).numpy()\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;31m# ff.argmax(axis=-1)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;31m# next(iter(val_dataset.batch(16)))\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;31mAttributeError\u001b[0m: '_UserObject' object has no attribute 'predict_on_batch'"]}],"source":["# imported.predict_on_batch(next(iter(val_dataset.batch(16)))).numpy()\n","# ff = new_model(next(iter(val_dataset.batch(16)))).numpy()\n","# ff.argmax(axis=-1)\n","\n","# next(iter(val_dataset.batch(16)))"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":328},"executionInfo":{"elapsed":11195,"status":"error","timestamp":1668500364772,"user":{"displayName":"Furqan Ali","userId":"08783436873128206665"},"user_tz":-540},"id":"-Ir185RFa4jG","outputId":"d7b2395a-7623-4a0e-926b-0a9a7d365bc9"},"outputs":[{"ename":"TypeError","evalue":"ignored","output_type":"error","traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)","\u001b[0;32m<ipython-input-21-6f7daa9f9863>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mpath\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"/content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/distilbert/weights/\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mmodel\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkeras\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmodels\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload_model\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py\u001b[0m in \u001b[0;36merror_handler\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 65\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# pylint: disable=broad-except\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 66\u001b[0m \u001b[0mfiltered_tb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_process_traceback_frames\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0me\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__traceback__\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 67\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwith_traceback\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfiltered_tb\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 68\u001b[0m \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 69\u001b[0m \u001b[0;32mdel\u001b[0m \u001b[0mfiltered_tb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/keras/saving/saved_model/load.py\u001b[0m in \u001b[0;36mcommon_spec\u001b[0;34m(x, y)\u001b[0m\n\u001b[1;32m 1149\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mresult\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1150\u001b[0m \u001b[0;31m# Please file a bug if you are being hindered by this error.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1151\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf'No common supertype of {x} and {y}.'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1152\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1153\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;31mTypeError\u001b[0m: No common supertype of TensorSpec(shape=(None, None), dtype=tf.int64, name=None) and TensorSpec(shape=(None, 100), dtype=tf.int32, name='input_ids/attention_mask')."]}],"source":["path = \"/content/drive/MyDrive/Colab Notebooks/Thesis and paper_work/distilbert/weights/\"\n","model = tf.keras.models.load_model(path)"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"_KUOt2yo6FVs"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"q_3GYKOK6FYS"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"KvRaymJu6Fay"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"nNw1S0Jm6Fc9"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"fTSzj1F06FfP"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"lQSiPFAd6FhN"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"URohonso6FjJ"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"lmXecIhs6Fm9"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"7EUOOSRn6Fo8"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"p6Gq50fr6Fsb"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"e8WzNWhjb011"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"OWkoZSuAb05D"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"6R4oWfbtb07q"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"4UtIQhMRb0_I"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"V96zQzWrb1Ep"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"WoKXCCqOb1Ik"},"outputs":[],"source":[]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Ko6_zmyTb1L7"},"outputs":[],"source":[]}],"metadata":{"accelerator":"GPU","colab":{"machine_shape":"hm","provenance":[],"mount_file_id":"1nXGlSvHY4Qusg4foOTj5F2Fe3RdU3GAv","authorship_tag":"ABX9TyOhugmnQP1ZtewsYB75/pX3"},"gpuClass":"premium","kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"name":"python"},"widgets":{"application/vnd.jupyter.widget-state+json":{"c6e857e1358a44e3be91f434cf7cd993":{"model_module":"@jupyter-widgets/controls","model_name":"HBoxModel","model_module_version":"1.5.0","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_421edeb2726f47658501a2417ac85e46","IPY_MODEL_a27f53987d194560b2fb84c3f17b1189","IPY_MODEL_d79255132ec7431aa8a03a4b84b26c7a"],"layout":"IPY_MODEL_b85557703f254028859a811215da5770"}},"421edeb2726f47658501a2417ac85e46":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_f09e7ab52c2142d59301a43df16bd31d","placeholder":"","style":"IPY_MODEL_f6fbad0807474909ba2fa52e08aec210","value":"Downloading: 100%"}},"a27f53987d194560b2fb84c3f17b1189":{"model_module":"@jupyter-widgets/controls","model_name":"FloatProgressModel","model_module_version":"1.5.0","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_1eea61660258492da7a5611c1ae3e0f7","max":231508,"min":0,"orientation":"horizontal","style":"IPY_MODEL_a95a611817d1438b8bb0d9cdd14db8db","value":231508}},"d79255132ec7431aa8a03a4b84b26c7a":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_eac91592f7814611aca7fbfb6ea052c0","placeholder":"","style":"IPY_MODEL_d6f6d000d0fb441bb918480cae45e801","value":" 232k/232k [00:00<00:00, 361kB/s]"}},"b85557703f254028859a811215da5770":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"f09e7ab52c2142d59301a43df16bd31d":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"f6fbad0807474909ba2fa52e08aec210":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"1eea61660258492da7a5611c1ae3e0f7":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"a95a611817d1438b8bb0d9cdd14db8db":{"model_module":"@jupyter-widgets/controls","model_name":"ProgressStyleModel","model_module_version":"1.5.0","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":""}},"eac91592f7814611aca7fbfb6ea052c0":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"d6f6d000d0fb441bb918480cae45e801":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"519dff3adfaf484facee9a183d95f7c4":{"model_module":"@jupyter-widgets/controls","model_name":"HBoxModel","model_module_version":"1.5.0","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_ac9c43816bb142c2b287e5916b1d6d6d","IPY_MODEL_9cb110f84f6c433ba5837935c34f6da3","IPY_MODEL_0057990f4b514d1abd2ddfb7ebd07d5c"],"layout":"IPY_MODEL_2c4e605e5bc8477cb6c85e3b8ba95ce1"}},"ac9c43816bb142c2b287e5916b1d6d6d":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_bb997f736cfb43f2a51caa1413ebc93d","placeholder":"","style":"IPY_MODEL_378b7979ff604b8d87c1349d562c2722","value":"Downloading: 100%"}},"9cb110f84f6c433ba5837935c34f6da3":{"model_module":"@jupyter-widgets/controls","model_name":"FloatProgressModel","model_module_version":"1.5.0","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_8ebed8d7fd6c479788e5c143a62b5101","max":28,"min":0,"orientation":"horizontal","style":"IPY_MODEL_12df3bb664d74ca6964c9a1a0cca0692","value":28}},"0057990f4b514d1abd2ddfb7ebd07d5c":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_b700d222675349289ac1d476f42bd5cd","placeholder":"","style":"IPY_MODEL_f9efb91d6e83405fb0100f0f223c3c27","value":" 28.0/28.0 [00:00<00:00, 1.13kB/s]"}},"2c4e605e5bc8477cb6c85e3b8ba95ce1":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"bb997f736cfb43f2a51caa1413ebc93d":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"378b7979ff604b8d87c1349d562c2722":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"8ebed8d7fd6c479788e5c143a62b5101":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"12df3bb664d74ca6964c9a1a0cca0692":{"model_module":"@jupyter-widgets/controls","model_name":"ProgressStyleModel","model_module_version":"1.5.0","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":""}},"b700d222675349289ac1d476f42bd5cd":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"f9efb91d6e83405fb0100f0f223c3c27":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"6e754175b534438a8044a4e66db90b79":{"model_module":"@jupyter-widgets/controls","model_name":"HBoxModel","model_module_version":"1.5.0","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_7feacac800204bfabbc9eff6db54c5d7","IPY_MODEL_efe39c5db99b45239a8317d80f217472","IPY_MODEL_e675fcdd75af4b54b297469ac089ab4f"],"layout":"IPY_MODEL_fed090b513b74c50b4d1b6dabacc1a7d"}},"7feacac800204bfabbc9eff6db54c5d7":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_d297a9d6d38246fd8664053188fe3ce1","placeholder":"","style":"IPY_MODEL_d3e2f8d174ee4194a4b578e12c34bca8","value":"Downloading: 100%"}},"efe39c5db99b45239a8317d80f217472":{"model_module":"@jupyter-widgets/controls","model_name":"FloatProgressModel","model_module_version":"1.5.0","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_21933542ae724aec8147e11a10fa6d26","max":570,"min":0,"orientation":"horizontal","style":"IPY_MODEL_4a6ecf68478545d4a51488c35e992207","value":570}},"e675fcdd75af4b54b297469ac089ab4f":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_3d7fb3791b324a8093bf05fc830ad3a9","placeholder":"","style":"IPY_MODEL_bf08d49674e6430c8d8ef3991ffddab5","value":" 570/570 [00:00<00:00, 22.3kB/s]"}},"fed090b513b74c50b4d1b6dabacc1a7d":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"d297a9d6d38246fd8664053188fe3ce1":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"d3e2f8d174ee4194a4b578e12c34bca8":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"21933542ae724aec8147e11a10fa6d26":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"4a6ecf68478545d4a51488c35e992207":{"model_module":"@jupyter-widgets/controls","model_name":"ProgressStyleModel","model_module_version":"1.5.0","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":""}},"3d7fb3791b324a8093bf05fc830ad3a9":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"bf08d49674e6430c8d8ef3991ffddab5":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"dbe9caa5970d4ed9ac389aed5d43fb60":{"model_module":"@jupyter-widgets/controls","model_name":"HBoxModel","model_module_version":"1.5.0","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_bcb471593e114e7ab9e66d22ef4eac29","IPY_MODEL_ce49422e870a4df2a24476f40aa5ce4d","IPY_MODEL_eed740200b854d40bb1ffcf7952de707"],"layout":"IPY_MODEL_875fad684f4046c1a366fa7572d82b8b"}},"bcb471593e114e7ab9e66d22ef4eac29":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_3673d748a55646b19976bee1f566b990","placeholder":"","style":"IPY_MODEL_b3da0c4ae7394f8b9be2c5c8dcaff730","value":"Downloading: 100%"}},"ce49422e870a4df2a24476f40aa5ce4d":{"model_module":"@jupyter-widgets/controls","model_name":"FloatProgressModel","model_module_version":"1.5.0","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_2d5f691e190045c08532f189caefbfa2","max":536063208,"min":0,"orientation":"horizontal","style":"IPY_MODEL_43f682f069284572989a48251e9c1a63","value":536063208}},"eed740200b854d40bb1ffcf7952de707":{"model_module":"@jupyter-widgets/controls","model_name":"HTMLModel","model_module_version":"1.5.0","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_f7f2c34505f34cb78f9fe38428d320e5","placeholder":"","style":"IPY_MODEL_08f109590bfa4e9c83c499a309744a39","value":" 536M/536M [00:08<00:00, 67.4MB/s]"}},"875fad684f4046c1a366fa7572d82b8b":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"3673d748a55646b19976bee1f566b990":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"b3da0c4ae7394f8b9be2c5c8dcaff730":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"2d5f691e190045c08532f189caefbfa2":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"43f682f069284572989a48251e9c1a63":{"model_module":"@jupyter-widgets/controls","model_name":"ProgressStyleModel","model_module_version":"1.5.0","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":""}},"f7f2c34505f34cb78f9fe38428d320e5":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","model_module_version":"1.2.0","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"08f109590bfa4e9c83c499a309744a39":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","model_module_version":"1.5.0","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}}}}},"nbformat":4,"nbformat_minor":0}