From 8fc4af36d7a18bfb5fae0fdf55340898b98fe109 Mon Sep 17 00:00:00 2001 From: jcollopy-tulane Date: Mon, 29 Apr 2024 03:19:44 -0500 Subject: [PATCH] Pickle --- nlp/cli.py | 2 +- notebooks/Experiment-CNN-1.ipynb | 194 +++++++++++++++---------------- 2 files changed, 98 insertions(+), 98 deletions(-) diff --git a/nlp/cli.py b/nlp/cli.py index 9de5675..08b34fc 100644 --- a/nlp/cli.py +++ b/nlp/cli.py @@ -191,7 +191,7 @@ def process_with_tokenizer(text): recall = recall_score(y_val, predictions) print("Recall on Validation:", round(recall, 3)) - pickle.dump((cnn), open(cnn_path, 'wb')) + pickle.dump((cnn,), open(cnn_path, 'wb')) diff --git a/notebooks/Experiment-CNN-1.ipynb b/notebooks/Experiment-CNN-1.ipynb index 9716cca..f6d646e 100644 --- a/notebooks/Experiment-CNN-1.ipynb +++ b/notebooks/Experiment-CNN-1.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 33, + "execution_count": 49, "id": "70f2a5ec-67f6-4d3c-b912-717e401fc70e", "metadata": {}, "outputs": [], @@ -33,7 +33,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 50, "id": "7acbbe88-4550-41d6-b0bb-ede002bc4e0b", "metadata": {}, "outputs": [], @@ -45,10 +45,18 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 56, "id": "1eac01e8-3c62-469b-96ea-d4babd8f9348", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "87\n" + ] + } + ], "source": [ "tokenizer = Tokenizer()\n", "\n", @@ -58,16 +66,18 @@ "with open('tokenizer.pickle', 'wb') as handle:\n", " pickle.dump(tokenizer, handle, protocol=pickle.HIGHEST_PROTOCOL)\n", "\n", - "\n", "all_sequences = tokenizer.texts_to_sequences(texts)\n", "\n", "maxlen = np.percentile([len(x) for x in all_sequences], 95) # 95th percentile\n", + "print(int(maxlen))\n", "\n", "vocab_size = len(tokenizer.word_index) + 1\n", "\n", - "maxlen = 100\n", - "X_train = pad_sequences(X_train, padding='post', maxlen=maxlen)\n", - "X_val = pad_sequences(X_val, padding='post', maxlen=maxlen)\n", + "X_train_sequences = tokenizer.texts_to_sequences(train_df[\"Comment_Adj\"])\n", + "X_val_sequences = tokenizer.texts_to_sequences(val_df[\"Comment_Adj\"])\n", + "\n", + "X_train = pad_sequences(X_train_sequences, padding='post', maxlen=87)\n", + "X_val = pad_sequences(X_val_sequences, padding='post', maxlen=87)\n", "label_encoder = LabelEncoder()\n", "y_train = label_encoder.fit_transform(train_df[\"Result_Bin\"])\n", "y_val = label_encoder.fit_transform(val_df[\"Result_Bin\"])" @@ -75,7 +85,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 55, "id": "7f61ab0b-4594-456c-9b22-440cf9c5fabe", "metadata": {}, "outputs": [ @@ -84,150 +94,140 @@ "output_type": "stream", "text": [ "Training model with configuration: filter = 16, kernel = 4, num_1 = 40, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.5883\n", + "Validation Accuracy: 0.5892\n", "Training model with configuration: filter = 16, kernel = 4, num_1 = 40, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6041\n", + "Validation Accuracy: 0.5975\n", "Training model with configuration: filter = 16, kernel = 4, num_1 = 40, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6344\n", + "Validation Accuracy: 0.6195\n", "Training model with configuration: filter = 16, kernel = 4, num_1 = 40, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6375\n", - "Training model with configuration: filter = 16, kernel = 4, num_1 = 70, lr = 0.01, dropout_rate = 0.5\n", "Validation Accuracy: 0.6191\n", + "Training model with configuration: filter = 16, kernel = 4, num_1 = 70, lr = 0.01, dropout_rate = 0.5\n", + "Validation Accuracy: 0.5975\n", "Training model with configuration: filter = 16, kernel = 4, num_1 = 70, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6033\n", + "Validation Accuracy: 0.6120\n", "Training model with configuration: filter = 16, kernel = 4, num_1 = 70, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6221\n", + "Validation Accuracy: 0.6292\n", "Training model with configuration: filter = 16, kernel = 4, num_1 = 70, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6252\n", + "Validation Accuracy: 0.6213\n", "Training model with configuration: filter = 16, kernel = 4, num_1 = 100, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6156\n", + "Validation Accuracy: 0.5879\n", "Training model with configuration: filter = 16, kernel = 4, num_1 = 100, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6142\n", + "Validation Accuracy: 0.6221\n", "Training model with configuration: filter = 16, kernel = 4, num_1 = 100, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6204\n", + "Validation Accuracy: 0.6322\n", "Training model with configuration: filter = 16, kernel = 4, num_1 = 100, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6226\n", + "Validation Accuracy: 0.6318\n", "Training model with configuration: filter = 16, kernel = 6, num_1 = 40, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.5439\n", + "Validation Accuracy: 0.5848\n", "Training model with configuration: filter = 16, kernel = 6, num_1 = 40, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.5791\n", + "Validation Accuracy: 0.5743\n", "Training model with configuration: filter = 16, kernel = 6, num_1 = 40, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6371\n", + "Validation Accuracy: 0.6314\n", "Training model with configuration: filter = 16, kernel = 6, num_1 = 40, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6230\n", + "Validation Accuracy: 0.6318\n", "Training model with configuration: filter = 16, kernel = 6, num_1 = 70, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6169\n", + "Validation Accuracy: 0.5637\n", "Training model with configuration: filter = 16, kernel = 6, num_1 = 70, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.5839\n", + "Validation Accuracy: 0.5936\n", "Training model with configuration: filter = 16, kernel = 6, num_1 = 70, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6287\n", + "Validation Accuracy: 0.6252\n", "Training model with configuration: filter = 16, kernel = 6, num_1 = 70, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6274\n", + "Validation Accuracy: 0.6270\n", "Training model with configuration: filter = 16, kernel = 6, num_1 = 100, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6147\n", + "Validation Accuracy: 0.6156\n", "Training model with configuration: filter = 16, kernel = 6, num_1 = 100, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6353\n", + "Validation Accuracy: 0.6103\n", "Training model with configuration: filter = 16, kernel = 6, num_1 = 100, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6221\n", + "Validation Accuracy: 0.6314\n", "Training model with configuration: filter = 16, kernel = 6, num_1 = 100, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6178\n", + "Validation Accuracy: 0.6336\n", "Training model with configuration: filter = 32, kernel = 4, num_1 = 40, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6186\n", + "Validation Accuracy: 0.6054\n", "Training model with configuration: filter = 32, kernel = 4, num_1 = 40, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6270\n", + "Validation Accuracy: 0.6164\n", "Training model with configuration: filter = 32, kernel = 4, num_1 = 40, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6314\n", + "Validation Accuracy: 0.6362\n", "Training model with configuration: filter = 32, kernel = 4, num_1 = 40, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6301\n", + "Validation Accuracy: 0.6331\n", "Training model with configuration: filter = 32, kernel = 4, num_1 = 70, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6046\n", + "Validation Accuracy: 0.6090\n", "Training model with configuration: filter = 32, kernel = 4, num_1 = 70, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.5980\n", + "Validation Accuracy: 0.6024\n", "Training model with configuration: filter = 32, kernel = 4, num_1 = 70, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6265\n", + "Validation Accuracy: 0.6217\n", "Training model with configuration: filter = 32, kernel = 4, num_1 = 70, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6274\n", + "Validation Accuracy: 0.6292\n", "Training model with configuration: filter = 32, kernel = 4, num_1 = 100, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.5980\n", + "Validation Accuracy: 0.5813\n", "Training model with configuration: filter = 32, kernel = 4, num_1 = 100, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6243\n", + "Validation Accuracy: 0.6120\n", "Training model with configuration: filter = 32, kernel = 4, num_1 = 100, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6235\n", + "Validation Accuracy: 0.6296\n", "Training model with configuration: filter = 32, kernel = 4, num_1 = 100, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6327\n", + "Validation Accuracy: 0.6279\n", "Training model with configuration: filter = 32, kernel = 6, num_1 = 40, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.5694\n", + "Validation Accuracy: 0.5835\n", "Training model with configuration: filter = 32, kernel = 6, num_1 = 40, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.5435\n", + "Validation Accuracy: 0.6050\n", "Training model with configuration: filter = 32, kernel = 6, num_1 = 40, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6226\n", + "Validation Accuracy: 0.6314\n", "Training model with configuration: filter = 32, kernel = 6, num_1 = 40, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6327\n", + "Validation Accuracy: 0.6375\n", "Training model with configuration: filter = 32, kernel = 6, num_1 = 70, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.5659\n", + "Validation Accuracy: 0.5830\n", "Training model with configuration: filter = 32, kernel = 6, num_1 = 70, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.5857\n", + "Validation Accuracy: 0.6006\n", "Training model with configuration: filter = 32, kernel = 6, num_1 = 70, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6054\n", + "Validation Accuracy: 0.6292\n", "Training model with configuration: filter = 32, kernel = 6, num_1 = 70, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6182\n", + "Validation Accuracy: 0.6204\n", "Training model with configuration: filter = 32, kernel = 6, num_1 = 100, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6112\n", + "Validation Accuracy: 0.6116\n", "Training model with configuration: filter = 32, kernel = 6, num_1 = 100, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6199\n", + "Validation Accuracy: 0.5984\n", "Training model with configuration: filter = 32, kernel = 6, num_1 = 100, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6257\n", + "Validation Accuracy: 0.6301\n", "Training model with configuration: filter = 32, kernel = 6, num_1 = 100, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6380\n", + "Validation Accuracy: 0.6274\n", "Training model with configuration: filter = 48, kernel = 4, num_1 = 40, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.5338\n", + "Validation Accuracy: 0.5940\n", "Training model with configuration: filter = 48, kernel = 4, num_1 = 40, lr = 0.01, dropout_rate = 0.6\n", "Validation Accuracy: 0.6226\n", "Training model with configuration: filter = 48, kernel = 4, num_1 = 40, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6279\n", + "Validation Accuracy: 0.6340\n", "Training model with configuration: filter = 48, kernel = 4, num_1 = 40, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6305\n", + "Validation Accuracy: 0.6406\n", "Training model with configuration: filter = 48, kernel = 4, num_1 = 70, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6059\n", + "Validation Accuracy: 0.6125\n", "Training model with configuration: filter = 48, kernel = 4, num_1 = 70, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6296\n", + "Validation Accuracy: 0.6301\n", "Training model with configuration: filter = 48, kernel = 4, num_1 = 70, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6235\n", + "Validation Accuracy: 0.6208\n", "Training model with configuration: filter = 48, kernel = 4, num_1 = 70, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6287\n", + "Validation Accuracy: 0.6327\n", "Training model with configuration: filter = 48, kernel = 4, num_1 = 100, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.4811\n", - "Training model with configuration: filter = 48, kernel = 4, num_1 = 100, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.5663\n", - "Training model with configuration: filter = 48, kernel = 4, num_1 = 100, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6283\n", - "Training model with configuration: filter = 48, kernel = 4, num_1 = 100, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6296\n", - "Training model with configuration: filter = 48, kernel = 6, num_1 = 40, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6134\n", - "Training model with configuration: filter = 48, kernel = 6, num_1 = 40, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6257\n", - "Training model with configuration: filter = 48, kernel = 6, num_1 = 40, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6235\n", - "Training model with configuration: filter = 48, kernel = 6, num_1 = 40, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6252\n", - "Training model with configuration: filter = 48, kernel = 6, num_1 = 70, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6134\n", - "Training model with configuration: filter = 48, kernel = 6, num_1 = 70, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.5677\n", - "Training model with configuration: filter = 48, kernel = 6, num_1 = 70, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6191\n", - "Training model with configuration: filter = 48, kernel = 6, num_1 = 70, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6221\n", - "Training model with configuration: filter = 48, kernel = 6, num_1 = 100, lr = 0.01, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6063\n", - "Training model with configuration: filter = 48, kernel = 6, num_1 = 100, lr = 0.01, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6081\n", - "Training model with configuration: filter = 48, kernel = 6, num_1 = 100, lr = 0.001, dropout_rate = 0.5\n", - "Validation Accuracy: 0.6292\n", - "Training model with configuration: filter = 48, kernel = 6, num_1 = 100, lr = 0.001, dropout_rate = 0.6\n", - "Validation Accuracy: 0.6257\n", - "The best model has parameters: filter = 32, kernel = 6, num_1 = 100, lr = 0.001, dropout_rate = 0.6 with accuracy = 0.638.\n" + "Validation Accuracy: 0.5764\n", + "Training model with configuration: filter = 48, kernel = 4, num_1 = 100, lr = 0.01, dropout_rate = 0.6\n" + ] + }, + { + "ename": "KeyboardInterrupt", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[55], line 47\u001b[0m\n\u001b[1;32m 45\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTraining model with configuration:\u001b[39m\u001b[38;5;124m\"\u001b[39m, model_desc)\n\u001b[1;32m 46\u001b[0m model \u001b[38;5;241m=\u001b[39m CNN_model_adj(\u001b[38;5;28mfilter\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mfilter\u001b[39m, kernel \u001b[38;5;241m=\u001b[39m kernel, num_1 \u001b[38;5;241m=\u001b[39m num, lr \u001b[38;5;241m=\u001b[39m lr, dropout_rate \u001b[38;5;241m=\u001b[39m rate)\n\u001b[0;32m---> 47\u001b[0m history \u001b[38;5;241m=\u001b[39m \u001b[43mmodel\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfit\u001b[49m\u001b[43m(\u001b[49m\u001b[43mX_train\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43my_train\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 48\u001b[0m \u001b[43m\u001b[49m\u001b[43mepochs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m30\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 49\u001b[0m \u001b[43m\u001b[49m\u001b[43mverbose\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 50\u001b[0m \u001b[43m\u001b[49m\u001b[43mvalidation_data\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mX_val\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43my_val\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 51\u001b[0m \u001b[43m\u001b[49m\u001b[43mbatch_size\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1000\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43mearly_stopping\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 52\u001b[0m val_loss, val_accuracy \u001b[38;5;241m=\u001b[39m model\u001b[38;5;241m.\u001b[39mevaluate(X_val, y_val, verbose\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[1;32m 53\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mValidation Accuracy: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mval_accuracy\u001b[38;5;132;01m:\u001b[39;00m\u001b[38;5;124m.4f\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", + "File \u001b[0;32m/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/keras/utils/traceback_utils.py:65\u001b[0m, in \u001b[0;36mfilter_traceback..error_handler\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 63\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 64\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m---> 65\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 66\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 67\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m _process_traceback_frames(e\u001b[38;5;241m.\u001b[39m__traceback__)\n", + "File \u001b[0;32m/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/keras/engine/training.py:1685\u001b[0m, in \u001b[0;36mModel.fit\u001b[0;34m(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)\u001b[0m\n\u001b[1;32m 1677\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m tf\u001b[38;5;241m.\u001b[39mprofiler\u001b[38;5;241m.\u001b[39mexperimental\u001b[38;5;241m.\u001b[39mTrace(\n\u001b[1;32m 1678\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtrain\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 1679\u001b[0m epoch_num\u001b[38;5;241m=\u001b[39mepoch,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1682\u001b[0m _r\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m,\n\u001b[1;32m 1683\u001b[0m ):\n\u001b[1;32m 1684\u001b[0m callbacks\u001b[38;5;241m.\u001b[39mon_train_batch_begin(step)\n\u001b[0;32m-> 1685\u001b[0m tmp_logs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtrain_function\u001b[49m\u001b[43m(\u001b[49m\u001b[43miterator\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1686\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m data_handler\u001b[38;5;241m.\u001b[39mshould_sync:\n\u001b[1;32m 1687\u001b[0m context\u001b[38;5;241m.\u001b[39masync_wait()\n", + "File \u001b[0;32m/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py:150\u001b[0m, in \u001b[0;36mfilter_traceback..error_handler\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 148\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 149\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 150\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 151\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 152\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m _process_traceback_frames(e\u001b[38;5;241m.\u001b[39m__traceback__)\n", + "File \u001b[0;32m/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py:894\u001b[0m, in \u001b[0;36mFunction.__call__\u001b[0;34m(self, *args, **kwds)\u001b[0m\n\u001b[1;32m 891\u001b[0m compiler \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mxla\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_jit_compile \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnonXla\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 893\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m OptionalXlaContext(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_jit_compile):\n\u001b[0;32m--> 894\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 896\u001b[0m new_tracing_count \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mexperimental_get_tracing_count()\n\u001b[1;32m 897\u001b[0m without_tracing \u001b[38;5;241m=\u001b[39m (tracing_count \u001b[38;5;241m==\u001b[39m new_tracing_count)\n", + "File \u001b[0;32m/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py:926\u001b[0m, in \u001b[0;36mFunction._call\u001b[0;34m(self, *args, **kwds)\u001b[0m\n\u001b[1;32m 923\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_lock\u001b[38;5;241m.\u001b[39mrelease()\n\u001b[1;32m 924\u001b[0m \u001b[38;5;66;03m# In this case we have created variables on the first call, so we run the\u001b[39;00m\n\u001b[1;32m 925\u001b[0m \u001b[38;5;66;03m# defunned version which is guaranteed to never create variables.\u001b[39;00m\n\u001b[0;32m--> 926\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_no_variable_creation_fn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# pylint: disable=not-callable\u001b[39;00m\n\u001b[1;32m 927\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_variable_creation_fn \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 928\u001b[0m \u001b[38;5;66;03m# Release the lock early so that multiple threads can perform the call\u001b[39;00m\n\u001b[1;32m 929\u001b[0m \u001b[38;5;66;03m# in parallel.\u001b[39;00m\n\u001b[1;32m 930\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_lock\u001b[38;5;241m.\u001b[39mrelease()\n", + "File \u001b[0;32m/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py:143\u001b[0m, in \u001b[0;36mTracingCompiler.__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 140\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_lock:\n\u001b[1;32m 141\u001b[0m (concrete_function,\n\u001b[1;32m 142\u001b[0m filtered_flat_args) \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_maybe_define_function(args, kwargs)\n\u001b[0;32m--> 143\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mconcrete_function\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_flat\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 144\u001b[0m \u001b[43m \u001b[49m\u001b[43mfiltered_flat_args\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcaptured_inputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconcrete_function\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcaptured_inputs\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/monomorphic_function.py:1757\u001b[0m, in \u001b[0;36mConcreteFunction._call_flat\u001b[0;34m(self, args, captured_inputs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1753\u001b[0m possible_gradient_type \u001b[38;5;241m=\u001b[39m gradients_util\u001b[38;5;241m.\u001b[39mPossibleTapeGradientTypes(args)\n\u001b[1;32m 1754\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (possible_gradient_type \u001b[38;5;241m==\u001b[39m gradients_util\u001b[38;5;241m.\u001b[39mPOSSIBLE_GRADIENT_TYPES_NONE\n\u001b[1;32m 1755\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m executing_eagerly):\n\u001b[1;32m 1756\u001b[0m \u001b[38;5;66;03m# No tape is watching; skip to running the function.\u001b[39;00m\n\u001b[0;32m-> 1757\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_build_call_outputs(\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_inference_function\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcall\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1758\u001b[0m \u001b[43m \u001b[49m\u001b[43mctx\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcancellation_manager\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcancellation_manager\u001b[49m\u001b[43m)\u001b[49m)\n\u001b[1;32m 1759\u001b[0m forward_backward \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_select_forward_and_backward_functions(\n\u001b[1;32m 1760\u001b[0m args,\n\u001b[1;32m 1761\u001b[0m possible_gradient_type,\n\u001b[1;32m 1762\u001b[0m executing_eagerly)\n\u001b[1;32m 1763\u001b[0m forward_function, args_with_tangents \u001b[38;5;241m=\u001b[39m forward_backward\u001b[38;5;241m.\u001b[39mforward()\n", + "File \u001b[0;32m/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/monomorphic_function.py:381\u001b[0m, in \u001b[0;36m_EagerDefinedFunction.call\u001b[0;34m(self, ctx, args, cancellation_manager)\u001b[0m\n\u001b[1;32m 379\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m _InterpolateFunctionError(\u001b[38;5;28mself\u001b[39m):\n\u001b[1;32m 380\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m cancellation_manager \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 381\u001b[0m outputs \u001b[38;5;241m=\u001b[39m \u001b[43mexecute\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexecute\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 382\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mstr\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msignature\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mname\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 383\u001b[0m \u001b[43m \u001b[49m\u001b[43mnum_outputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_num_outputs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 384\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 385\u001b[0m \u001b[43m \u001b[49m\u001b[43mattrs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mattrs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 386\u001b[0m \u001b[43m \u001b[49m\u001b[43mctx\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mctx\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 387\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 388\u001b[0m outputs \u001b[38;5;241m=\u001b[39m execute\u001b[38;5;241m.\u001b[39mexecute_with_cancellation(\n\u001b[1;32m 389\u001b[0m \u001b[38;5;28mstr\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msignature\u001b[38;5;241m.\u001b[39mname),\n\u001b[1;32m 390\u001b[0m num_outputs\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_num_outputs,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 393\u001b[0m ctx\u001b[38;5;241m=\u001b[39mctx,\n\u001b[1;32m 394\u001b[0m cancellation_manager\u001b[38;5;241m=\u001b[39mcancellation_manager)\n", + "File \u001b[0;32m/opt/anaconda3/envs/testenv/lib/python3.9/site-packages/tensorflow/python/eager/execute.py:52\u001b[0m, in \u001b[0;36mquick_execute\u001b[0;34m(op_name, num_outputs, inputs, attrs, ctx, name)\u001b[0m\n\u001b[1;32m 50\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 51\u001b[0m ctx\u001b[38;5;241m.\u001b[39mensure_initialized()\n\u001b[0;32m---> 52\u001b[0m tensors \u001b[38;5;241m=\u001b[39m \u001b[43mpywrap_tfe\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mTFE_Py_Execute\u001b[49m\u001b[43m(\u001b[49m\u001b[43mctx\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_handle\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdevice_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mop_name\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 53\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mattrs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnum_outputs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 54\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m core\u001b[38;5;241m.\u001b[39m_NotOkStatusException \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 55\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m name \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n", + "\u001b[0;31mKeyboardInterrupt\u001b[0m: " ] } ], @@ -244,7 +244,7 @@ " model = Sequential()\n", " model.add(layers.Embedding(input_dim=vocab_size, \n", " output_dim=200, \n", - " input_length=maxlen))\n", + " input_length=87))\n", " model.add(Conv1D(filters=filter, kernel_size=kernel, activation=\"relu\"))\n", " model.add(MaxPooling1D(pool_size=2))\n", " model.add(layers.Flatten())\n",