{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "2b46cd0f-ae6d-4781-8dab-89df1f880ada", "metadata": { "execution": { "iopub.execute_input": "2024-03-31T14:00:16.074098Z", "iopub.status.busy": "2024-03-31T14:00:16.073728Z", "iopub.status.idle": "2024-03-31T14:00:16.461502Z", "shell.execute_reply": "2024-03-31T14:00:16.460565Z", "shell.execute_reply.started": "2024-03-31T14:00:16.074074Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "No config specified, defaulting to: emotion/split\n", "Reusing dataset emotion (/root/.cache/huggingface/datasets/dair-ai___emotion/split/1.0.0/cca5efe2dfeb58c1d098e0f9eeb200e9927d889b5a03c67097275dfb5fe463bd)\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "c3b3103a90124dfea0bbec49829f8746", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/3 [00:00\n", "Int64Index: 18000 entries, 0 to 1999\n", "Data columns (total 2 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 text 18000 non-null object\n", " 1 label 18000 non-null int64 \n", "dtypes: int64(1), object(1)\n", "memory usage: 421.9+ KB\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
textlabel
0i didnt feel humiliated0
1i can go from feeling so hopeless to so damned...0
2im grabbing a minute to post i feel greedy wrong3
3i am ever feeling nostalgic about the fireplac...2
4i am feeling grouchy3
\n", "
" ], "text/plain": [ " text label\n", "0 i didnt feel humiliated 0\n", "1 i can go from feeling so hopeless to so damned... 0\n", "2 im grabbing a minute to post i feel greedy wrong 3\n", "3 i am ever feeling nostalgic about the fireplac... 2\n", "4 i am feeling grouchy 3" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "\n", "dataset_train = dataset['train'].to_pandas()\n", "dataset_test = dataset['test'].to_pandas()\n", "\n", "complete_dataset = pd.concat([dataset_train, dataset_test])\n", "\n", "complete_dataset.info()\n", "complete_dataset.head()" ] }, { "cell_type": "code", "execution_count": 4, "id": "0cfc926c-70df-4089-9b2e-f201faa223df", "metadata": { "execution": { "iopub.execute_input": "2024-03-31T14:00:16.500097Z", "iopub.status.busy": "2024-03-31T14:00:16.499802Z", "iopub.status.idle": "2024-03-31T14:00:16.505424Z", "shell.execute_reply": "2024-03-31T14:00:16.504005Z", "shell.execute_reply.started": "2024-03-31T14:00:16.500071Z" } }, "outputs": [], "source": [ "# imports for model creation\n", "import tensorflow as tf\n", "from keras import layers\n", "from keras import losses\n", "import keras\n", "from tensorflow.keras.preprocessing.text import Tokenizer\n", "from tensorflow.keras.preprocessing.sequence import pad_sequences" ] }, { "cell_type": "code", "execution_count": 5, "id": "eb4bab6b-ae99-4fae-bf0b-ca91be630db3", "metadata": { "execution": { "iopub.execute_input": "2024-03-31T14:00:16.508818Z", "iopub.status.busy": "2024-03-31T14:00:16.508418Z", "iopub.status.idle": "2024-03-31T14:00:17.259616Z", "shell.execute_reply": "2024-03-31T14:00:17.258634Z", "shell.execute_reply.started": "2024-03-31T14:00:16.508782Z" } }, "outputs": [], "source": [ "tokenizer = Tokenizer()\n", "tokenizer.fit_on_texts(complete_dataset['text'])\n", "\n", "vocab_size = len(tokenizer.word_index) + 1\n", "max_length = 200 # max words in a sentence\n", "embedding_dim = 50 # TODO: need to adjust accordingly\n", "\n", "X_train = tokenizer.texts_to_sequences(dataset_train['text'])\n", "X_train = pad_sequences(X_train, maxlen=max_length, padding='post')\n", "\n", "X_test = tokenizer.texts_to_sequences(dataset_test['text'])\n", "X_test = pad_sequences(X_test, maxlen=max_length, padding='post')\n", "\n", "y_train = dataset_train['label']\n", "y_test = dataset_test['label']\n", "\n", "from keras.utils import to_categorical\n", "\n", "num_classes = 6 # Assuming you have 3 classes\n", "y_train_encoded = to_categorical(y_train, num_classes=num_classes)\n", "y_test_encoded = to_categorical(y_test, num_classes=num_classes)" ] }, { "cell_type": "code", "execution_count": 6, "id": "d7202d74-95c7-4bb2-aea5-54481dfcafd6", "metadata": { "execution": { "iopub.execute_input": "2024-03-31T14:00:17.261577Z", "iopub.status.busy": "2024-03-31T14:00:17.261236Z", "iopub.status.idle": "2024-03-31T14:00:17.267983Z", "shell.execute_reply": "2024-03-31T14:00:17.267053Z", "shell.execute_reply.started": "2024-03-31T14:00:17.261539Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(16000, 200)\n", "(2000, 200)\n", "(16000,)\n", "(2000,)\n" ] } ], "source": [ "labels = complete_dataset['label']\n", "\n", "print(X_train.shape)\n", "print(X_test.shape)\n", "print(y_train.shape)\n", "print(y_test.shape)" ] }, { "cell_type": "code", "execution_count": 7, "id": "738e3137-7ea4-4e71-9395-773e537083cf", "metadata": { "execution": { "iopub.execute_input": "2024-03-31T14:00:17.269524Z", "iopub.status.busy": "2024-03-31T14:00:17.269276Z", "iopub.status.idle": "2024-03-31T14:00:17.328258Z", "shell.execute_reply": "2024-03-31T14:00:17.327093Z", "shell.execute_reply.started": "2024-03-31T14:00:17.269498Z" } }, "outputs": [], "source": [ "# Build the model\n", "model = keras.Sequential([\n", " keras.layers.Embedding(input_dim=vocab_size, output_dim=embedding_dim, input_shape=(max_length,)),\n", " keras.layers.GlobalAveragePooling1D(),\n", " keras.layers.Dense(32, activation='relu'),\n", " keras.layers.Dense(6, activation='sigmoid')\n", "])" ] }, { "cell_type": "code", "execution_count": 8, "id": "cd072f39-99e6-44f0-8c7f-106a0055c43b", "metadata": { "execution": { "iopub.execute_input": "2024-03-31T14:00:17.330501Z", "iopub.status.busy": "2024-03-31T14:00:17.330148Z", "iopub.status.idle": "2024-03-31T14:00:17.340754Z", "shell.execute_reply": "2024-03-31T14:00:17.339909Z", "shell.execute_reply.started": "2024-03-31T14:00:17.330466Z" } }, "outputs": [], "source": [ "# Compile the model\n", "model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])" ] }, { "cell_type": "code", "execution_count": 9, "id": "72ad6548-5d1c-4221-88c7-014dcbaea0ee", "metadata": { "execution": { "iopub.execute_input": "2024-03-31T14:00:17.342873Z", "iopub.status.busy": "2024-03-31T14:00:17.342494Z", "iopub.status.idle": "2024-03-31T14:00:17.347797Z", "shell.execute_reply": "2024-03-31T14:00:17.346354Z", "shell.execute_reply.started": "2024-03-31T14:00:17.342836Z" } }, "outputs": [], "source": [ "# split the dataset into train and test\n", "# from sklearn.model_selection import train_test_split\n", "\n", "# X_train, X_test, y_train, y_test = train_test_split(, labels, test_size=0.3, random_state=42, shuffle=True)\n", "# X_train" ] }, { "cell_type": "code", "execution_count": 12, "id": "9267da90-7a84-49d1-94d0-04a2cd3062e0", "metadata": { "execution": { "iopub.execute_input": "2024-03-31T14:00:43.055635Z", "iopub.status.busy": "2024-03-31T14:00:43.055255Z", "iopub.status.idle": "2024-03-31T14:01:14.962372Z", "shell.execute_reply": "2024-03-31T14:01:14.961429Z", "shell.execute_reply.started": "2024-03-31T14:00:43.055606Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Epoch 1/15\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2024-03-31 14:12:18.969565: E tensorflow/stream_executor/cuda/cuda_blas.cc:232] failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED\n", "2024-03-31 14:12:18.969636: E tensorflow/stream_executor/cuda/cuda_blas.cc:234] Failure to initialize cublas may be due to OOM (cublas needs some free memory when you initialize it, and your deep-learning framework may have preallocated more than its fair share), or may be because this binary was not built with support for the GPU in your machine.\n", "2024-03-31 14:12:18.969674: W tensorflow/core/framework/op_kernel.cc:1745] OP_REQUIRES failed at matmul_op_impl.h:438 : INTERNAL: Attempting to perform BLAS operation using StreamExecutor without BLAS support\n" ] }, { "ename": "InternalError", "evalue": "Graph execution error:\n\nDetected at node 'sequential/dense/MatMul' defined at (most recent call last):\n File \"/usr/lib/python3.9/runpy.py\", line 197, in _run_module_as_main\n return _run_code(code, main_globals, None,\n File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel_launcher.py\", line 17, in \n app.launch_new_instance()\n File \"/usr/local/lib/python3.9/dist-packages/traitlets/config/application.py\", line 1041, in launch_instance\n app.start()\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/kernelapp.py\", line 712, in start\n self.io_loop.start()\n File \"/usr/local/lib/python3.9/dist-packages/tornado/platform/asyncio.py\", line 199, in start\n self.asyncio_loop.run_forever()\n File \"/usr/lib/python3.9/asyncio/base_events.py\", line 601, in run_forever\n self._run_once()\n File \"/usr/lib/python3.9/asyncio/base_events.py\", line 1905, in _run_once\n handle._run()\n File \"/usr/lib/python3.9/asyncio/events.py\", line 80, in _run\n self._context.run(self._callback, *self._args)\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/kernelbase.py\", line 510, in dispatch_queue\n await self.process_one()\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/kernelbase.py\", line 499, in process_one\n await dispatch(*args)\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/kernelbase.py\", line 406, in dispatch_shell\n await result\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/kernelbase.py\", line 730, in execute_request\n reply_content = await reply_content\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/ipkernel.py\", line 383, in do_execute\n res = shell.run_cell(\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/zmqshell.py\", line 528, in run_cell\n return super().run_cell(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py\", line 2885, in run_cell\n result = self._run_cell(\n File \"/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py\", line 2940, in _run_cell\n return runner(coro)\n File \"/usr/local/lib/python3.9/dist-packages/IPython/core/async_helpers.py\", line 129, in _pseudo_sync_runner\n coro.send(None)\n File \"/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py\", line 3139, in run_cell_async\n has_raised = await self.run_ast_nodes(code_ast.body, cell_name,\n File \"/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py\", line 3318, in run_ast_nodes\n if await self.run_code(code, result, async_=asy):\n File \"/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py\", line 3378, in run_code\n exec(code_obj, self.user_global_ns, self.user_ns)\n File \"/tmp/ipykernel_517/2691274767.py\", line 2, in \n model.fit(X_train, y_train_encoded, epochs=15, batch_size=32, validation_data=(X_test, y_test_encoded))\n File \"/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py\", line 64, in error_handler\n return fn(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/training.py\", line 1409, in fit\n tmp_logs = self.train_function(iterator)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/training.py\", line 1051, in train_function\n return step_function(self, iterator)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/training.py\", line 1040, in step_function\n outputs = model.distribute_strategy.run(run_step, args=(data,))\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/training.py\", line 1030, in run_step\n outputs = model.train_step(data)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/training.py\", line 889, in train_step\n y_pred = self(x, training=True)\n File \"/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py\", line 64, in error_handler\n return fn(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/training.py\", line 490, in __call__\n return super().__call__(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py\", line 64, in error_handler\n return fn(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/base_layer.py\", line 1014, in __call__\n outputs = call_fn(inputs, *args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py\", line 92, in error_handler\n return fn(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/sequential.py\", line 374, in call\n return super(Sequential, self).call(inputs, training=training, mask=mask)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/functional.py\", line 458, in call\n return self._run_internal_graph(\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/functional.py\", line 596, in _run_internal_graph\n outputs = node.layer(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py\", line 64, in error_handler\n return fn(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/base_layer.py\", line 1014, in __call__\n outputs = call_fn(inputs, *args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py\", line 92, in error_handler\n return fn(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/layers/core/dense.py\", line 221, in call\n outputs = tf.matmul(a=inputs, b=self.kernel)\nNode: 'sequential/dense/MatMul'\nAttempting to perform BLAS operation using StreamExecutor without BLAS support\n\t [[{{node sequential/dense/MatMul}}]] [Op:__inference_train_function_727]", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mInternalError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn [12], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# train the model\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \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_encoded\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mepochs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m15\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbatch_size\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m32\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalidation_data\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mX_test\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43my_test_encoded\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n", "File \u001b[0;32m/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py:67\u001b[0m, in \u001b[0;36mfilter_traceback..error_handler\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 65\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: \u001b[38;5;66;03m# pylint: disable=broad-except\u001b[39;00m\n\u001b[1;32m 66\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m _process_traceback_frames(e\u001b[38;5;241m.\u001b[39m__traceback__)\n\u001b[0;32m---> 67\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m e\u001b[38;5;241m.\u001b[39mwith_traceback(filtered_tb) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28mNone\u001b[39m\n\u001b[1;32m 68\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[1;32m 69\u001b[0m \u001b[38;5;28;01mdel\u001b[39;00m filtered_tb\n", "File \u001b[0;32m/usr/local/lib/python3.9/dist-packages/tensorflow/python/eager/execute.py:54\u001b[0m, in \u001b[0;36mquick_execute\u001b[0;34m(op_name, num_outputs, inputs, attrs, ctx, name)\u001b[0m\n\u001b[1;32m 52\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 53\u001b[0m ctx\u001b[38;5;241m.\u001b[39mensure_initialized()\n\u001b[0;32m---> 54\u001b[0m tensors \u001b[38;5;241m=\u001b[39m pywrap_tfe\u001b[38;5;241m.\u001b[39mTFE_Py_Execute(ctx\u001b[38;5;241m.\u001b[39m_handle, device_name, op_name,\n\u001b[1;32m 55\u001b[0m inputs, attrs, num_outputs)\n\u001b[1;32m 56\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 57\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;31mInternalError\u001b[0m: Graph execution error:\n\nDetected at node 'sequential/dense/MatMul' defined at (most recent call last):\n File \"/usr/lib/python3.9/runpy.py\", line 197, in _run_module_as_main\n return _run_code(code, main_globals, None,\n File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel_launcher.py\", line 17, in \n app.launch_new_instance()\n File \"/usr/local/lib/python3.9/dist-packages/traitlets/config/application.py\", line 1041, in launch_instance\n app.start()\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/kernelapp.py\", line 712, in start\n self.io_loop.start()\n File \"/usr/local/lib/python3.9/dist-packages/tornado/platform/asyncio.py\", line 199, in start\n self.asyncio_loop.run_forever()\n File \"/usr/lib/python3.9/asyncio/base_events.py\", line 601, in run_forever\n self._run_once()\n File \"/usr/lib/python3.9/asyncio/base_events.py\", line 1905, in _run_once\n handle._run()\n File \"/usr/lib/python3.9/asyncio/events.py\", line 80, in _run\n self._context.run(self._callback, *self._args)\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/kernelbase.py\", line 510, in dispatch_queue\n await self.process_one()\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/kernelbase.py\", line 499, in process_one\n await dispatch(*args)\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/kernelbase.py\", line 406, in dispatch_shell\n await result\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/kernelbase.py\", line 730, in execute_request\n reply_content = await reply_content\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/ipkernel.py\", line 383, in do_execute\n res = shell.run_cell(\n File \"/usr/local/lib/python3.9/dist-packages/ipykernel/zmqshell.py\", line 528, in run_cell\n return super().run_cell(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py\", line 2885, in run_cell\n result = self._run_cell(\n File \"/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py\", line 2940, in _run_cell\n return runner(coro)\n File \"/usr/local/lib/python3.9/dist-packages/IPython/core/async_helpers.py\", line 129, in _pseudo_sync_runner\n coro.send(None)\n File \"/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py\", line 3139, in run_cell_async\n has_raised = await self.run_ast_nodes(code_ast.body, cell_name,\n File \"/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py\", line 3318, in run_ast_nodes\n if await self.run_code(code, result, async_=asy):\n File \"/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py\", line 3378, in run_code\n exec(code_obj, self.user_global_ns, self.user_ns)\n File \"/tmp/ipykernel_517/2691274767.py\", line 2, in \n model.fit(X_train, y_train_encoded, epochs=15, batch_size=32, validation_data=(X_test, y_test_encoded))\n File \"/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py\", line 64, in error_handler\n return fn(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/training.py\", line 1409, in fit\n tmp_logs = self.train_function(iterator)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/training.py\", line 1051, in train_function\n return step_function(self, iterator)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/training.py\", line 1040, in step_function\n outputs = model.distribute_strategy.run(run_step, args=(data,))\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/training.py\", line 1030, in run_step\n outputs = model.train_step(data)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/training.py\", line 889, in train_step\n y_pred = self(x, training=True)\n File \"/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py\", line 64, in error_handler\n return fn(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/training.py\", line 490, in __call__\n return super().__call__(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py\", line 64, in error_handler\n return fn(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/base_layer.py\", line 1014, in __call__\n outputs = call_fn(inputs, *args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py\", line 92, in error_handler\n return fn(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/sequential.py\", line 374, in call\n return super(Sequential, self).call(inputs, training=training, mask=mask)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/functional.py\", line 458, in call\n return self._run_internal_graph(\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/functional.py\", line 596, in _run_internal_graph\n outputs = node.layer(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py\", line 64, in error_handler\n return fn(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/engine/base_layer.py\", line 1014, in __call__\n outputs = call_fn(inputs, *args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py\", line 92, in error_handler\n return fn(*args, **kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/keras/layers/core/dense.py\", line 221, in call\n outputs = tf.matmul(a=inputs, b=self.kernel)\nNode: 'sequential/dense/MatMul'\nAttempting to perform BLAS operation using StreamExecutor without BLAS support\n\t [[{{node sequential/dense/MatMul}}]] [Op:__inference_train_function_727]" ] } ], "source": [ "# train the model\n", "model.fit(X_train, y_train_encoded, epochs=15, batch_size=32, validation_data=(X_test, y_test_encoded))" ] }, { "cell_type": "code", "execution_count": 48, "id": "24e17bec-2fbe-400f-9273-a5abe823f193", "metadata": { "execution": { "iopub.execute_input": "2024-03-31T14:01:20.843282Z", "iopub.status.busy": "2024-03-31T14:01:20.842873Z", "iopub.status.idle": "2024-03-31T14:01:21.062240Z", "shell.execute_reply": "2024-03-31T14:01:21.061522Z", "shell.execute_reply.started": "2024-03-31T14:01:20.843253Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "63/63 [==============================] - 0s 2ms/step - loss: 0.5242 - accuracy: 0.8580\n" ] }, { "data": { "text/plain": [ "0.8579999804496765" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Evaluate the model\n", "loss, accuracy = model.evaluate(X_test, y_test_encoded)\n", "accuracy" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.16" } }, "nbformat": 4, "nbformat_minor": 5 }