Last active
June 25, 2020 20:32
-
-
Save luminousmen/c891af01748fcf62ec46ff6d9e2fa4dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from pathlib import Path\n", | |
"\n", | |
"import pandas as pd\n", | |
"import numpy as np\n", | |
"\n", | |
"from fastai.text import *\n", | |
"from fastai import *" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"data_path = Path('data')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"df = pd.read_csv(\"toxic_comments.csv\")\n", | |
"df2 = pd.read_csv(\"toxic_comments2.csv\")\n", | |
"df = pd.concat([df, df2]) # <--- final data" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"df['toxic'] = df['toxic'] + df['severe_toxic']\n", | |
"df = df.drop(columns=[\"id\", 'severe_toxic'])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"df.loc[df['toxic'] == 2] = 1" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"df = df.dropna()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"mask = ((df['toxic'] == 0) & (df['obscene'] == 0) & (df['threat'] == 0) & (df['insult'] == 0) & (df['identity_hate'] == 0))\n", | |
"df_sample = pd.concat([df[mask].sample(20000), df[~mask].sample(22000)])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"valid_mask = np.random.rand(len(df_sample)) < 0.8\n", | |
"train_df = df_sample[valid_mask]\n", | |
"valid_df = df_sample[~valid_mask]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"train_df.to_csv(\"train_df\", index=False)\n", | |
"valid_df.to_csv(\"valid_df\", index=False)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"train_df = pd.read_csv(\"train_df\")\n", | |
"valid_df = pd.read_csv(\"valid_df\")" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Text classificator" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 35, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"data_bunch = TextDataBunch.from_df(\n", | |
" data_path, \n", | |
" train_df=train_df, \n", | |
" valid_df=valid_df,\n", | |
" text_cols=['comment_text'], \n", | |
" label_cols=['toxic', 'obscene', 'threat', 'insult', 'identity_hate'],\n", | |
" bs=32\n", | |
")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 36, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th>text</th>\n", | |
" <th>target</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <td>xxbos i xxup am xxup an xxup loser xxrep 4 = i xxup am xxup an xxup loser = = = = i xxup am xxup an xxup loser xxrep 4 = i xxup am xxup an xxup loser = = = = i xxup am xxup an xxup loser xxrep 4 = i xxup am xxup an xxup loser = = = = i xxup am xxup an xxup</td>\n", | |
" <td>toxic</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>xxbos xxup it xxup is xxup users xxup like xxup you xxup that xxup make xxup wikipedia a xxup shithole . xxup you're a xxup fucker xxup and xxup get a xxup life . i xxup could xxup vandalize xxup all i xxup want xxup and i xxup dare xxup you xxup to xxup earse xxup it xxup agoian . xxup change xxup your xxup name xxup to xxup fuckbot</td>\n", | |
" <td>toxic;obscene;threat;insult</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>xxbos xxup tommy2010 xxup is a xxup nigger xxup tommy2010 xxup is a xxup nigger xxup tommy2010 xxup is a xxup nigger xxup tommy2010 xxup is a xxup nigger xxup tommy2010 xxup is a xxup nigger xxup tommy2010 xxup is a xxup nigger xxup tommy2010 xxup is a xxup nigger xxup tommy2010 xxup is a xxup nigger xxup tommy2010 xxup is a xxup nigger xxup tommy2010 xxup is a xxup</td>\n", | |
" <td>toxic;insult;identity_hate</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>xxbos xxup fuck xxup you xxup all ! xxup fuck xxup you xxup all ! xxup fuck xxup you xxup all ! xxup fuck xxup you xxup all ! xxup fuck xxup you xxup all ! xxup fuck xxup you xxup all ! xxup fuck xxup you xxup all ! xxup fuck xxup you xxup all ! xxup fuck xxup you xxup all ! xxup fuck xxup you xxup all</td>\n", | |
" <td>toxic;obscene;insult</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>xxbos \" \\n \\n xxmaj after reviewing the deletion , i think the error is technical . i am on a xxmaj hughes xxmaj sat network that uses transparent proxies . xxmaj this was causing me to log in and out from page to page . xxmaj the original article which was not the correct article went through and posted when i switched to xxup ssl wiki server .</td>\n", | |
" <td></td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"data_bunch.show_batch()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 37, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"learn = text_classifier_learner(data_bunch, AWD_LSTM, drop_mult=0.5)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 38, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"\n", | |
" <div>\n", | |
" <style>\n", | |
" /* Turns off some styling */\n", | |
" progress {\n", | |
" /* gets rid of default border in Firefox and Opera. */\n", | |
" border: none;\n", | |
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n", | |
" background-size: auto;\n", | |
" }\n", | |
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n", | |
" background: #F44336;\n", | |
" }\n", | |
" </style>\n", | |
" <progress value='0' class='' max='1', style='width:300px; height:20px; vertical-align: middle;'></progress>\n", | |
" 0.00% [0/1 00:00<00:00]\n", | |
" </div>\n", | |
" \n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: left;\">\n", | |
" <th>epoch</th>\n", | |
" <th>train_loss</th>\n", | |
" <th>valid_loss</th>\n", | |
" <th>time</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" </tbody>\n", | |
"</table><p>\n", | |
"\n", | |
" <div>\n", | |
" <style>\n", | |
" /* Turns off some styling */\n", | |
" progress {\n", | |
" /* gets rid of default border in Firefox and Opera. */\n", | |
" border: none;\n", | |
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n", | |
" background-size: auto;\n", | |
" }\n", | |
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n", | |
" background: #F44336;\n", | |
" }\n", | |
" </style>\n", | |
" <progress value='97' class='' max='1047', style='width:300px; height:20px; vertical-align: middle;'></progress>\n", | |
" 9.26% [97/1047 00:18<03:00 2.3478]\n", | |
" </div>\n", | |
" " | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"LR Finder is complete, type {learner_name}.recorder.plot() to see the graph.\n", | |
"Min numerical gradient: 6.92E-02\n", | |
"Min loss divided by 10: 4.37E-02\n" | |
] | |
}, | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEGCAYAAAB/+QKOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8GearUAAAgAElEQVR4nO3de3xcdZ3/8ddnJpN72qZNeqEtvYQWqAWKVORaYBEo/ERAUVHxgmhFwdt6w7381l19/NZd3fWy4AKyiMgiuq5oUQS8IXdsCy20hUJ6oYm9JU2bNpfOZGY+vz/mpJ2mkzZtczIzyfv5eMwjc875njmfmabzyfd6zN0RERHpK5LvAEREpDApQYiISE5KECIikpMShIiI5KQEISIiOZXkO4DBVFdX59OnT893GCIiRWPZsmWt7l6f61ioCcLMFgLfAaLAne7+9T7Ha4G7gAZgD/Bhd18ZHNsA7AZSQNLd5x/qetOnT2fp0qWD+h5ERIYzM3u9v2OhJQgziwK3AhcBzcASM1vs7quziv0NsNzdrzKzE4LyF2Ydv8DdW8OKUURE+hdmH8TpQKO7r3P3BHA/cEWfMnOA3wO4+yvAdDObEGJMIiIyQGEmiMlAU9Z2c7Av2wrg7QBmdjowDZgSHHPgUTNbZmaL+ruImS0ys6VmtrSlpWXQghcRGenCTBCWY1/fdT2+DtSa2X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MzKrdvSO4x/CtwGvu/q18xyXSl2oQIkPvo0Gn9SoyzVq35zkekZxUgxARkZxUgxARkZyUIEREJCclCBERyUkJQkREclKCEBGRnP4/vmhSmHV9z7EAAAAASUVORK5CYII=\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"learn.lr_find()\n", | |
"learn.recorder.plot(suggestion=True)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 41, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: left;\">\n", | |
" <th>epoch</th>\n", | |
" <th>train_loss</th>\n", | |
" <th>valid_loss</th>\n", | |
" <th>time</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <td>0</td>\n", | |
" <td>0.483192</td>\n", | |
" <td>0.616437</td>\n", | |
" <td>02:36</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>1</td>\n", | |
" <td>0.490093</td>\n", | |
" <td>0.576607</td>\n", | |
" <td>02:40</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"learn.fit_one_cycle(2, slice(2.09E-01, 4.37E-02) , moms=(0.8,0.7))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 42, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: left;\">\n", | |
" <th>epoch</th>\n", | |
" <th>train_loss</th>\n", | |
" <th>valid_loss</th>\n", | |
" <th>time</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <td>0</td>\n", | |
" <td>0.397737</td>\n", | |
" <td>0.385522</td>\n", | |
" <td>02:48</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"learn.freeze_to(-2)\n", | |
"learn.fit_one_cycle(1, 3.63E-03, moms=(0.8,0.7))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 43, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"learn.save('classificator')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 44, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"RNNLearner(data=TextClasDataBunch;\n", | |
"\n", | |
"Train: LabelList (33516 items)\n", | |
"x: TextList\n", | |
"xxbos \" \n", | |
" \n", | |
" : : : i do not understand what you propose . \",xxbos xxup -i actually like the list . xxmaj there 's only 10 videos ... but i understand the need to simplify things . xxmaj maybe you should just list the current # 1 video , instead of the whole list ?,xxbos xxmaj what sort of idiot has never heard of the xxmaj xxunk ? xxmaj you xxmaj americans are not cultured at all !,xxbos \" : \" \" xxmaj on xxmaj june 30 , 2006 , an estimated xxunk % of black men were in prison or jail , compared to 1.9 % of xxmaj hispanic men and xxunk % of white men . \" \" \",xxbos \" \n", | |
" \n", | |
" xxmaj trolls and xxmaj xxunk \n", | |
" i have been xxunk from the discussion page so i can not really defend myself against the darkness ( the user darkness shine ) so let me have my say please the user has also attacked others calling them \" \" dimwits \" \" and reverted more 10 times today as have i so if justice is to be done we both should be blocked or warned or whatever the admins do to punish cheers again 109.150.60.235 \"\n", | |
"y: MultiCategoryList\n", | |
",,,,\n", | |
"Path: data;\n", | |
"\n", | |
"Valid: LabelList (8484 items)\n", | |
"x: TextList\n", | |
"xxbos xxmaj how is it xxrep 4 . \n", | |
" \n", | |
" xxmaj vandlism ? i created that picture , i could take it off if i wanted to .,xxbos xxmaj drafting xxmaj articles,xxbos \" \n", | |
" xxmaj sorry you feel that way , but aparently you do n't understand that you do n't xxup wp : xxup own xxup wp . xxunk \",xxbos \" \n", | |
" \n", | |
" xxmaj compromise ( i hope ) : xxmaj start a xxmaj minor xxmaj houses of a xxmaj song of xxmaj ice and xxmaj fire or xxunk . xxmaj move the info about their history there , as well as the key points there . xxmaj move complete xxmaj xxunk and xxmaj xxunk bios to minor characters . xxmaj however , i think this particular article should be kept around for 2 reasons : \n", | |
" 1 . xxmaj simply put , it 's a good idea to xxunk information . xxmaj somebody who 's reading minor houses and wants to read about xxmaj xxunk and xxmaj xxunk will find it easier and more intuitive to go to a xxmaj house xxmaj xxunk entry than a minor characters entry . \n", | |
" 2 . xxmaj from all indications , the xxmaj xxunk will be major players in xxup xxunk ( i think xxmaj martin saying that a xxmaj xxunk is coming back is better than mere \" \" speculation \" \" ) . xxmaj every major xxmaj xxunk institution that 's had a xxup pov centered on it ( major houses , xxmaj night 's xxmaj watch , xxmaj citadel ) has an article . xxmaj it seems pointless to get rid of this now and bring it back a year later . \n", | |
" i think that \" \" current \" \" is both too ambigious and potentially xxunk . xxmaj the former may be more verbose , but it 's also more exact and less troublesome . \",xxbos xxmaj xxunk conspiracy theory \n", | |
" \n", | |
" xxmaj thanks for your message on my talk page . i 've replied there but i 've noticed now that the xxmaj space xxmaj preservation xxmaj act situation is already properly explained in the article , at the end of the xxmaj xxunk vs xxunk section . xxmaj regards .\n", | |
"y: MultiCategoryList\n", | |
",,,,\n", | |
"Path: data;\n", | |
"\n", | |
"Test: None, model=SequentialRNN(\n", | |
" (0): MultiBatchEncoder(\n", | |
" (module): AWD_LSTM(\n", | |
" (encoder): Embedding(33832, 400, padding_idx=1)\n", | |
" (encoder_dp): EmbeddingDropout(\n", | |
" (emb): Embedding(33832, 400, padding_idx=1)\n", | |
" )\n", | |
" (rnns): ModuleList(\n", | |
" (0): WeightDropout(\n", | |
" (module): LSTM(400, 1152, batch_first=True)\n", | |
" )\n", | |
" (1): WeightDropout(\n", | |
" (module): LSTM(1152, 1152, batch_first=True)\n", | |
" )\n", | |
" (2): WeightDropout(\n", | |
" (module): LSTM(1152, 400, batch_first=True)\n", | |
" )\n", | |
" )\n", | |
" (input_dp): RNNDropout()\n", | |
" (hidden_dps): ModuleList(\n", | |
" (0): RNNDropout()\n", | |
" (1): RNNDropout()\n", | |
" (2): RNNDropout()\n", | |
" )\n", | |
" )\n", | |
" )\n", | |
" (1): PoolingLinearClassifier(\n", | |
" (layers): Sequential(\n", | |
" (0): BatchNorm1d(1200, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n", | |
" (1): Dropout(p=0.2, inplace=False)\n", | |
" (2): Linear(in_features=1200, out_features=50, bias=True)\n", | |
" (3): ReLU(inplace=True)\n", | |
" (4): BatchNorm1d(50, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n", | |
" (5): Dropout(p=0.1, inplace=False)\n", | |
" (6): Linear(in_features=50, out_features=5, bias=True)\n", | |
" )\n", | |
" )\n", | |
"), opt_func=functools.partial(<class 'torch.optim.adam.Adam'>, betas=(0.9, 0.99)), loss_func=FlattenedLoss of BCEWithLogitsLoss(), metrics=[], true_wd=True, bn_wd=True, wd=0.01, train_bn=True, path=PosixPath('data'), model_dir='models', callback_fns=[functools.partial(<class 'fastai.basic_train.Recorder'>, add_time=True, silent=False)], callbacks=[RNNTrainer\n", | |
"learn: ...\n", | |
"alpha: 2.0\n", | |
"beta: 1.0], layer_groups=[Sequential(\n", | |
" (0): Embedding(33832, 400, padding_idx=1)\n", | |
" (1): EmbeddingDropout(\n", | |
" (emb): Embedding(33832, 400, padding_idx=1)\n", | |
" )\n", | |
"), Sequential(\n", | |
" (0): WeightDropout(\n", | |
" (module): LSTM(400, 1152, batch_first=True)\n", | |
" )\n", | |
" (1): RNNDropout()\n", | |
"), Sequential(\n", | |
" (0): WeightDropout(\n", | |
" (module): LSTM(1152, 1152, batch_first=True)\n", | |
" )\n", | |
" (1): RNNDropout()\n", | |
"), Sequential(\n", | |
" (0): WeightDropout(\n", | |
" (module): LSTM(1152, 400, batch_first=True)\n", | |
" )\n", | |
" (1): RNNDropout()\n", | |
"), Sequential(\n", | |
" (0): PoolingLinearClassifier(\n", | |
" (layers): Sequential(\n", | |
" (0): BatchNorm1d(1200, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n", | |
" (1): Dropout(p=0.2, inplace=False)\n", | |
" (2): Linear(in_features=1200, out_features=50, bias=True)\n", | |
" (3): ReLU(inplace=True)\n", | |
" (4): BatchNorm1d(50, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n", | |
" (5): Dropout(p=0.1, inplace=False)\n", | |
" (6): Linear(in_features=50, out_features=5, bias=True)\n", | |
" )\n", | |
" )\n", | |
")], add_time=True, silent=False)" | |
] | |
}, | |
"execution_count": 44, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"learn.load('classificator')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 46, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/ipykernel_launcher.py:2: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n", | |
" \n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:264: TracerWarning: Converting a tensor to a Python index might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" for i in range(0, sl, self.bptt):\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:265: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" r, o = self.module(input[:,i: min(i+self.bptt, sl)])\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/models/awd_lstm.py:106: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" if bs!=self.bs:\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/models/awd_lstm.py:123: TracerWarning: Converting a tensor to a Python index might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" return one_param(self).new(self.n_dir, self.bs, nh).zero_()\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:266: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" if i>(sl-self.max_len):\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:267: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" masks.append(input[:,i: min(i+self.bptt, sl)] == self.pad_idx)\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:265: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" r, o = self.module(input[:,i: min(i+self.bptt, sl)])\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/models/awd_lstm.py:106: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" if bs!=self.bs:\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:266: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" if i>(sl-self.max_len):\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:267: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" masks.append(input[:,i: min(i+self.bptt, sl)] == self.pad_idx)\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:265: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" r, o = self.module(input[:,i: min(i+self.bptt, sl)])\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/models/awd_lstm.py:106: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" if bs!=self.bs:\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:266: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" if i>(sl-self.max_len):\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:267: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" masks.append(input[:,i: min(i+self.bptt, sl)] == self.pad_idx)\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:265: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" r, o = self.module(input[:,i: min(i+self.bptt, sl)])\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/models/awd_lstm.py:106: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" if bs!=self.bs:\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:266: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" if i>(sl-self.max_len):\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:267: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" masks.append(input[:,i: min(i+self.bptt, sl)] == self.pad_idx)\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:265: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" r, o = self.module(input[:,i: min(i+self.bptt, sl)])\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/models/awd_lstm.py:106: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" if bs!=self.bs:\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:266: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" if i>(sl-self.max_len):\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:267: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" masks.append(input[:,i: min(i+self.bptt, sl)] == self.pad_idx)\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:265: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" r, o = self.module(input[:,i: min(i+self.bptt, sl)])\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:265: TracerWarning: Converting a tensor to a Python index might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" r, o = self.module(input[:,i: min(i+self.bptt, sl)])\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/models/awd_lstm.py:106: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" if bs!=self.bs:\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:266: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" if i>(sl-self.max_len):\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:267: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" masks.append(input[:,i: min(i+self.bptt, sl)] == self.pad_idx)\n", | |
"/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai/text/learner.py:267: TracerWarning: Converting a tensor to a Python index might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", | |
" masks.append(input[:,i: min(i+self.bptt, sl)] == self.pad_idx)\n" | |
] | |
}, | |
{ | |
"ename": "RuntimeError", | |
"evalue": "Only tensors or tuples of tensors can be output from traced functions (getOutput at /opt/conda/conda-bld/pytorch_1579022060824/work/torch/csrc/jit/tracer.cpp:212)\nframe #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x47 (0x7ff1452e8627 in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libc10.so)\nframe #1: torch::jit::tracer::TracingState::getOutput(c10::IValue const&, unsigned long) + 0x334 (0x7ff14fd6e024 in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libtorch.so)\nframe #2: torch::jit::tracer::TracingState::getOutput(c10::IValue const&, unsigned long) + 0xfe (0x7ff14fd6ddee in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libtorch.so)\nframe #3: torch::jit::tracer::trace(std::vector<c10::IValue, std::allocator<c10::IValue> >, std::function<std::vector<c10::IValue, std::allocator<c10::IValue> > (std::vector<c10::IValue, std::allocator<c10::IValue> >)> const&, std::function<std::string (at::Tensor const&)>, bool, torch::jit::script::Module*) + 0x539 (0x7ff14fd759f9 in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libtorch.so)\nframe #4: <unknown function> + 0x767641 (0x7ff17c274641 in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libtorch_python.so)\nframe #5: <unknown function> + 0x781581 (0x7ff17c28e581 in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libtorch_python.so)\nframe #6: <unknown function> + 0x28ba06 (0x7ff17bd98a06 in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libtorch_python.so)\nframe #7: _PyMethodDef_RawFastCallKeywords + 0x264 (0x556db64acd24 in /opt/conda/envs/fastai/bin/python)\nframe #8: _PyCFunction_FastCallKeywords + 0x21 (0x556db64ace41 in /opt/conda/envs/fastai/bin/python)\nframe #9: _PyEval_EvalFrameDefault + 0x533a (0x556db651972a in /opt/conda/envs/fastai/bin/python)\nframe #10: _PyEval_EvalCodeWithName + 0xab8 (0x556db645cf08 in /opt/conda/envs/fastai/bin/python)\nframe #11: _PyFunction_FastCallKeywords + 0x387 (0x556db64ac527 in /opt/conda/envs/fastai/bin/python)\nframe #12: _PyEval_EvalFrameDefault + 0x416 (0x556db6514806 in /opt/conda/envs/fastai/bin/python)\nframe #13: _PyEval_EvalCodeWithName + 0x2f9 (0x556db645c749 in /opt/conda/envs/fastai/bin/python)\nframe #14: _PyFunction_FastCallKeywords + 0x325 (0x556db64ac4c5 in /opt/conda/envs/fastai/bin/python)\nframe #15: _PyEval_EvalFrameDefault + 0x4c89 (0x556db6519079 in /opt/conda/envs/fastai/bin/python)\nframe #16: _PyEval_EvalCodeWithName + 0x2f9 (0x556db645c749 in /opt/conda/envs/fastai/bin/python)\nframe #17: PyEval_EvalCodeEx + 0x44 (0x556db645d674 in /opt/conda/envs/fastai/bin/python)\nframe #18: PyEval_EvalCode + 0x1c (0x556db645d69c in /opt/conda/envs/fastai/bin/python)\nframe #19: <unknown function> + 0x1dd06d (0x556db652406d in /opt/conda/envs/fastai/bin/python)\nframe #20: _PyMethodDef_RawFastCallKeywords + 0xe9 (0x556db64acba9 in /opt/conda/envs/fastai/bin/python)\nframe #21: _PyCFunction_FastCallKeywords + 0x21 (0x556db64ace41 in /opt/conda/envs/fastai/bin/python)\nframe #22: _PyEval_EvalFrameDefault + 0x48d4 (0x556db6518cc4 in /opt/conda/envs/fastai/bin/python)\nframe #23: _PyGen_Send + 0x2a2 (0x556db64b5b12 in /opt/conda/envs/fastai/bin/python)\nframe #24: _PyEval_EvalFrameDefault + 0x1adc (0x556db6515ecc in /opt/conda/envs/fastai/bin/python)\nframe #25: _PyGen_Send + 0x2a2 (0x556db64b5b12 in /opt/conda/envs/fastai/bin/python)\nframe #26: _PyEval_EvalFrameDefault + 0x1adc (0x556db6515ecc in /opt/conda/envs/fastai/bin/python)\nframe #27: _PyGen_Send + 0x2a2 (0x556db64b5b12 in /opt/conda/envs/fastai/bin/python)\nframe #28: _PyMethodDef_RawFastCallKeywords + 0x8d (0x556db64acb4d in /opt/conda/envs/fastai/bin/python)\nframe #29: _PyMethodDescr_FastCallKeywords + 0x4f (0x556db64b494f in /opt/conda/envs/fastai/bin/python)\nframe #30: _PyEval_EvalFrameDefault + 0x4ddd (0x556db65191cd in /opt/conda/envs/fastai/bin/python)\nframe #31: _PyFunction_FastCallKeywords + 0xfb (0x556db64ac29b in /opt/conda/envs/fastai/bin/python)\nframe #32: _PyEval_EvalFrameDefault + 0x416 (0x556db6514806 in /opt/conda/envs/fastai/bin/python)\nframe #33: _PyFunction_FastCallKeywords + 0xfb (0x556db64ac29b in /opt/conda/envs/fastai/bin/python)\nframe #34: _PyEval_EvalFrameDefault + 0x6a0 (0x556db6514a90 in /opt/conda/envs/fastai/bin/python)\nframe #35: _PyEval_EvalCodeWithName + 0x2f9 (0x556db645c749 in /opt/conda/envs/fastai/bin/python)\nframe #36: _PyFunction_FastCallDict + 0x400 (0x556db645dab0 in /opt/conda/envs/fastai/bin/python)\nframe #37: _PyObject_Call_Prepend + 0x63 (0x556db647bb63 in /opt/conda/envs/fastai/bin/python)\nframe #38: PyObject_Call + 0x62 (0x556db646e522 in /opt/conda/envs/fastai/bin/python)\nframe #39: _PyEval_EvalFrameDefault + 0x1e53 (0x556db6516243 in /opt/conda/envs/fastai/bin/python)\nframe #40: _PyEval_EvalCodeWithName + 0x5da (0x556db645ca2a in /opt/conda/envs/fastai/bin/python)\nframe #41: _PyFunction_FastCallKeywords + 0x387 (0x556db64ac527 in /opt/conda/envs/fastai/bin/python)\nframe #42: _PyEval_EvalFrameDefault + 0x14e7 (0x556db65158d7 in /opt/conda/envs/fastai/bin/python)\nframe #43: <unknown function> + 0x16e5d9 (0x556db64b55d9 in /opt/conda/envs/fastai/bin/python)\nframe #44: _PyMethodDef_RawFastCallKeywords + 0xe9 (0x556db64acba9 in /opt/conda/envs/fastai/bin/python)\nframe #45: _PyCFunction_FastCallKeywords + 0x21 (0x556db64ace41 in /opt/conda/envs/fastai/bin/python)\nframe #46: _PyEval_EvalFrameDefault + 0x48d4 (0x556db6518cc4 in /opt/conda/envs/fastai/bin/python)\nframe #47: _PyEval_EvalCodeWithName + 0x5da (0x556db645ca2a in /opt/conda/envs/fastai/bin/python)\nframe #48: _PyFunction_FastCallKeywords + 0x387 (0x556db64ac527 in /opt/conda/envs/fastai/bin/python)\nframe #49: _PyEval_EvalFrameDefault + 0x6a0 (0x556db6514a90 in /opt/conda/envs/fastai/bin/python)\nframe #50: <unknown function> + 0x16e5d9 (0x556db64b55d9 in /opt/conda/envs/fastai/bin/python)\nframe #51: _PyMethodDef_RawFastCallKeywords + 0xe9 (0x556db64acba9 in /opt/conda/envs/fastai/bin/python)\nframe #52: _PyCFunction_FastCallKeywords + 0x21 (0x556db64ace41 in /opt/conda/envs/fastai/bin/python)\nframe #53: _PyEval_EvalFrameDefault + 0x48d4 (0x556db6518cc4 in /opt/conda/envs/fastai/bin/python)\nframe #54: _PyEval_EvalCodeWithName + 0x5da (0x556db645ca2a in /opt/conda/envs/fastai/bin/python)\nframe #55: _PyFunction_FastCallKeywords + 0x387 (0x556db64ac527 in /opt/conda/envs/fastai/bin/python)\nframe #56: _PyEval_EvalFrameDefault + 0x416 (0x556db6514806 in /opt/conda/envs/fastai/bin/python)\nframe #57: <unknown function> + 0x16e5d9 (0x556db64b55d9 in /opt/conda/envs/fastai/bin/python)\nframe #58: _PyMethodDef_RawFastCallKeywords + 0xe9 (0x556db64acba9 in /opt/conda/envs/fastai/bin/python)\nframe #59: _PyCFunction_FastCallKeywords + 0x21 (0x556db64ace41 in /opt/conda/envs/fastai/bin/python)\nframe #60: _PyEval_EvalFrameDefault + 0x48d4 (0x556db6518cc4 in /opt/conda/envs/fastai/bin/python)\nframe #61: _PyEval_EvalCodeWithName + 0x5da (0x556db645ca2a in /opt/conda/envs/fastai/bin/python)\nframe #62: _PyFunction_FastCallDict + 0x1d5 (0x556db645d885 in /opt/conda/envs/fastai/bin/python)\nframe #63: _PyObject_Call_Prepend + 0x63 (0x556db647bb63 in /opt/conda/envs/fastai/bin/python)\n", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", | |
"\u001b[0;32m<ipython-input-46-cf681b65882d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mtrace_input\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mones\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m400\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcuda\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[1;32m 2\u001b[0m \u001b[0mtrace_input\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtensor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrace_input\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mint64\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mjit_model\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjit\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtrace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlearn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfloat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtrace_input\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 4\u001b[0m \u001b[0mmodel_file\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'torch_model.pth'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjit\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msave\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mjit_model\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmodel_file\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;32m/opt/conda/envs/fastai/lib/python3.7/site-packages/torch/jit/__init__.py\u001b[0m in \u001b[0;36mtrace\u001b[0;34m(func, example_inputs, optimize, check_trace, check_inputs, check_tolerance, _force_outplace, _module_class, _compilation_unit)\u001b[0m\n\u001b[1;32m 880\u001b[0m return trace_module(func, {'forward': example_inputs}, None,\n\u001b[1;32m 881\u001b[0m \u001b[0mcheck_trace\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mwrap_check_inputs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcheck_inputs\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--> 882\u001b[0;31m check_tolerance, _force_outplace, _module_class)\n\u001b[0m\u001b[1;32m 883\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 884\u001b[0m if (hasattr(func, '__self__') and isinstance(func.__self__, torch.nn.Module) and\n", | |
"\u001b[0;32m/opt/conda/envs/fastai/lib/python3.7/site-packages/torch/jit/__init__.py\u001b[0m in \u001b[0;36mtrace_module\u001b[0;34m(mod, inputs, optimize, check_trace, check_inputs, check_tolerance, _force_outplace, _module_class, _compilation_unit)\u001b[0m\n\u001b[1;32m 1032\u001b[0m \u001b[0mfunc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmod\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmethod_name\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"forward\"\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod_name\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1033\u001b[0m \u001b[0mexample_inputs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmake_tuple\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexample_inputs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1034\u001b[0;31m \u001b[0mmodule\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_c\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_create_method_from_trace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmethod_name\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexample_inputs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvar_lookup_fn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0m_force_outplace\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 1035\u001b[0m \u001b[0mcheck_trace_method\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmodule\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_c\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_method\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmethod_name\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1036\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mRuntimeError\u001b[0m: Only tensors or tuples of tensors can be output from traced functions (getOutput at /opt/conda/conda-bld/pytorch_1579022060824/work/torch/csrc/jit/tracer.cpp:212)\nframe #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x47 (0x7ff1452e8627 in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libc10.so)\nframe #1: torch::jit::tracer::TracingState::getOutput(c10::IValue const&, unsigned long) + 0x334 (0x7ff14fd6e024 in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libtorch.so)\nframe #2: torch::jit::tracer::TracingState::getOutput(c10::IValue const&, unsigned long) + 0xfe (0x7ff14fd6ddee in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libtorch.so)\nframe #3: torch::jit::tracer::trace(std::vector<c10::IValue, std::allocator<c10::IValue> >, std::function<std::vector<c10::IValue, std::allocator<c10::IValue> > (std::vector<c10::IValue, std::allocator<c10::IValue> >)> const&, std::function<std::string (at::Tensor const&)>, bool, torch::jit::script::Module*) + 0x539 (0x7ff14fd759f9 in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libtorch.so)\nframe #4: <unknown function> + 0x767641 (0x7ff17c274641 in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libtorch_python.so)\nframe #5: <unknown function> + 0x781581 (0x7ff17c28e581 in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libtorch_python.so)\nframe #6: <unknown function> + 0x28ba06 (0x7ff17bd98a06 in /opt/conda/envs/fastai/lib/python3.7/site-packages/torch/lib/libtorch_python.so)\nframe #7: _PyMethodDef_RawFastCallKeywords + 0x264 (0x556db64acd24 in /opt/conda/envs/fastai/bin/python)\nframe #8: _PyCFunction_FastCallKeywords + 0x21 (0x556db64ace41 in /opt/conda/envs/fastai/bin/python)\nframe #9: _PyEval_EvalFrameDefault + 0x533a (0x556db651972a in /opt/conda/envs/fastai/bin/python)\nframe #10: _PyEval_EvalCodeWithName + 0xab8 (0x556db645cf08 in /opt/conda/envs/fastai/bin/python)\nframe #11: _PyFunction_FastCallKeywords + 0x387 (0x556db64ac527 in /opt/conda/envs/fastai/bin/python)\nframe #12: _PyEval_EvalFrameDefault + 0x416 (0x556db6514806 in /opt/conda/envs/fastai/bin/python)\nframe #13: _PyEval_EvalCodeWithName + 0x2f9 (0x556db645c749 in /opt/conda/envs/fastai/bin/python)\nframe #14: _PyFunction_FastCallKeywords + 0x325 (0x556db64ac4c5 in /opt/conda/envs/fastai/bin/python)\nframe #15: _PyEval_EvalFrameDefault + 0x4c89 (0x556db6519079 in /opt/conda/envs/fastai/bin/python)\nframe #16: _PyEval_EvalCodeWithName + 0x2f9 (0x556db645c749 in /opt/conda/envs/fastai/bin/python)\nframe #17: PyEval_EvalCodeEx + 0x44 (0x556db645d674 in /opt/conda/envs/fastai/bin/python)\nframe #18: PyEval_EvalCode + 0x1c (0x556db645d69c in /opt/conda/envs/fastai/bin/python)\nframe #19: <unknown function> + 0x1dd06d (0x556db652406d in /opt/conda/envs/fastai/bin/python)\nframe #20: _PyMethodDef_RawFastCallKeywords + 0xe9 (0x556db64acba9 in /opt/conda/envs/fastai/bin/python)\nframe #21: _PyCFunction_FastCallKeywords + 0x21 (0x556db64ace41 in /opt/conda/envs/fastai/bin/python)\nframe #22: _PyEval_EvalFrameDefault + 0x48d4 (0x556db6518cc4 in /opt/conda/envs/fastai/bin/python)\nframe #23: _PyGen_Send + 0x2a2 (0x556db64b5b12 in /opt/conda/envs/fastai/bin/python)\nframe #24: _PyEval_EvalFrameDefault + 0x1adc (0x556db6515ecc in /opt/conda/envs/fastai/bin/python)\nframe #25: _PyGen_Send + 0x2a2 (0x556db64b5b12 in /opt/conda/envs/fastai/bin/python)\nframe #26: _PyEval_EvalFrameDefault + 0x1adc (0x556db6515ecc in /opt/conda/envs/fastai/bin/python)\nframe #27: _PyGen_Send + 0x2a2 (0x556db64b5b12 in /opt/conda/envs/fastai/bin/python)\nframe #28: _PyMethodDef_RawFastCallKeywords + 0x8d (0x556db64acb4d in /opt/conda/envs/fastai/bin/python)\nframe #29: _PyMethodDescr_FastCallKeywords + 0x4f (0x556db64b494f in /opt/conda/envs/fastai/bin/python)\nframe #30: _PyEval_EvalFrameDefault + 0x4ddd (0x556db65191cd in /opt/conda/envs/fastai/bin/python)\nframe #31: _PyFunction_FastCallKeywords + 0xfb (0x556db64ac29b in /opt/conda/envs/fastai/bin/python)\nframe #32: _PyEval_EvalFrameDefault + 0x416 (0x556db6514806 in /opt/conda/envs/fastai/bin/python)\nframe #33: _PyFunction_FastCallKeywords + 0xfb (0x556db64ac29b in /opt/conda/envs/fastai/bin/python)\nframe #34: _PyEval_EvalFrameDefault + 0x6a0 (0x556db6514a90 in /opt/conda/envs/fastai/bin/python)\nframe #35: _PyEval_EvalCodeWithName + 0x2f9 (0x556db645c749 in /opt/conda/envs/fastai/bin/python)\nframe #36: _PyFunction_FastCallDict + 0x400 (0x556db645dab0 in /opt/conda/envs/fastai/bin/python)\nframe #37: _PyObject_Call_Prepend + 0x63 (0x556db647bb63 in /opt/conda/envs/fastai/bin/python)\nframe #38: PyObject_Call + 0x62 (0x556db646e522 in /opt/conda/envs/fastai/bin/python)\nframe #39: _PyEval_EvalFrameDefault + 0x1e53 (0x556db6516243 in /opt/conda/envs/fastai/bin/python)\nframe #40: _PyEval_EvalCodeWithName + 0x5da (0x556db645ca2a in /opt/conda/envs/fastai/bin/python)\nframe #41: _PyFunction_FastCallKeywords + 0x387 (0x556db64ac527 in /opt/conda/envs/fastai/bin/python)\nframe #42: _PyEval_EvalFrameDefault + 0x14e7 (0x556db65158d7 in /opt/conda/envs/fastai/bin/python)\nframe #43: <unknown function> + 0x16e5d9 (0x556db64b55d9 in /opt/conda/envs/fastai/bin/python)\nframe #44: _PyMethodDef_RawFastCallKeywords + 0xe9 (0x556db64acba9 in /opt/conda/envs/fastai/bin/python)\nframe #45: _PyCFunction_FastCallKeywords + 0x21 (0x556db64ace41 in /opt/conda/envs/fastai/bin/python)\nframe #46: _PyEval_EvalFrameDefault + 0x48d4 (0x556db6518cc4 in /opt/conda/envs/fastai/bin/python)\nframe #47: _PyEval_EvalCodeWithName + 0x5da (0x556db645ca2a in /opt/conda/envs/fastai/bin/python)\nframe #48: _PyFunction_FastCallKeywords + 0x387 (0x556db64ac527 in /opt/conda/envs/fastai/bin/python)\nframe #49: _PyEval_EvalFrameDefault + 0x6a0 (0x556db6514a90 in /opt/conda/envs/fastai/bin/python)\nframe #50: <unknown function> + 0x16e5d9 (0x556db64b55d9 in /opt/conda/envs/fastai/bin/python)\nframe #51: _PyMethodDef_RawFastCallKeywords + 0xe9 (0x556db64acba9 in /opt/conda/envs/fastai/bin/python)\nframe #52: _PyCFunction_FastCallKeywords + 0x21 (0x556db64ace41 in /opt/conda/envs/fastai/bin/python)\nframe #53: _PyEval_EvalFrameDefault + 0x48d4 (0x556db6518cc4 in /opt/conda/envs/fastai/bin/python)\nframe #54: _PyEval_EvalCodeWithName + 0x5da (0x556db645ca2a in /opt/conda/envs/fastai/bin/python)\nframe #55: _PyFunction_FastCallKeywords + 0x387 (0x556db64ac527 in /opt/conda/envs/fastai/bin/python)\nframe #56: _PyEval_EvalFrameDefault + 0x416 (0x556db6514806 in /opt/conda/envs/fastai/bin/python)\nframe #57: <unknown function> + 0x16e5d9 (0x556db64b55d9 in /opt/conda/envs/fastai/bin/python)\nframe #58: _PyMethodDef_RawFastCallKeywords + 0xe9 (0x556db64acba9 in /opt/conda/envs/fastai/bin/python)\nframe #59: _PyCFunction_FastCallKeywords + 0x21 (0x556db64ace41 in /opt/conda/envs/fastai/bin/python)\nframe #60: _PyEval_EvalFrameDefault + 0x48d4 (0x556db6518cc4 in /opt/conda/envs/fastai/bin/python)\nframe #61: _PyEval_EvalCodeWithName + 0x5da (0x556db645ca2a in /opt/conda/envs/fastai/bin/python)\nframe #62: _PyFunction_FastCallDict + 0x1d5 (0x556db645d885 in /opt/conda/envs/fastai/bin/python)\nframe #63: _PyObject_Call_Prepend + 0x63 (0x556db647bb63 in /opt/conda/envs/fastai/bin/python)\n" | |
] | |
} | |
], | |
"source": [ | |
"trace_input = torch.ones(1,400).cuda()\n", | |
"trace_input = torch.tensor(trace_input).to(torch.int64)\n", | |
"jit_model = torch.jit.trace(learn.model.float(), trace_input)\n", | |
"model_file='torch_model.pth'\n", | |
"torch.jit.save(jit_model, model_file)\n", | |
"# export classes text file\n", | |
"save_texts('classes.txt', data.classes)\n", | |
"tar_file='model.tar.gz'\n", | |
"classes_file='classes.txt'\n", | |
"# create a tarfile with the exported model and classes text file\n", | |
"with tarfile.open(tar_file, 'w:gz') as f:\n", | |
" f.add(model_file, arcname=model_file)\n", | |
" f.add(classes_file, arcname=classes_file)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.6" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment