"
]
diff --git a/22_word_embedding/supervised_word_embeddings.ipynb b/22_word_embedding/supervised_word_embeddings.ipynb
index b949e5e..f37b1aa 100644
--- a/22_word_embedding/supervised_word_embeddings.ipynb
+++ b/22_word_embedding/supervised_word_embeddings.ipynb
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -30,16 +30,16 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "[4, 23]"
+ "[19, 17]"
]
},
- "execution_count": 20,
+ "execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
@@ -50,14 +50,14 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "[[13, 21], [4, 23], [14, 17], [8, 15, 16], [22, 15, 29], [8, 21], [26, 15, 24], [16, 4], [16, 12], [4, 29]]\n"
+ "[[3, 13], [19, 17], [20, 11], [4, 21, 19], [27, 1, 19], [12, 13], [20, 1, 8], [26, 20], [26, 24], [7, 18]]\n"
]
}
],
@@ -69,23 +69,23 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "[[13 21 0 0]\n",
- " [ 4 23 0 0]\n",
- " [14 17 0 0]\n",
- " [ 8 15 16 0]\n",
- " [22 15 29 0]\n",
- " [ 8 21 0 0]\n",
- " [26 15 24 0]\n",
- " [16 4 0 0]\n",
- " [16 12 0 0]\n",
- " [ 4 29 0 0]]\n"
+ "[[ 3 13 0 0]\n",
+ " [19 17 0 0]\n",
+ " [20 11 0 0]\n",
+ " [ 4 21 19 0]\n",
+ " [27 1 19 0]\n",
+ " [12 13 0 0]\n",
+ " [20 1 8 0]\n",
+ " [26 20 0 0]\n",
+ " [26 24 0 0]\n",
+ " [ 7 18 0 0]]\n"
]
}
],
@@ -97,23 +97,32 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 6,
"metadata": {
"scrolled": true
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "c:\\Users\\Charanjeet Juneja\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\keras\\src\\layers\\core\\embedding.py:81: UserWarning: Do not pass an `input_shape`/`input_dim` argument to a layer. When using Sequential models, prefer using an `Input(shape)` object as the first layer in the model instead.\n",
+ " super().__init__(**kwargs)\n"
+ ]
+ }
+ ],
"source": [
"embeded_vector_size = 5\n",
"\n",
"model = Sequential()\n",
- "model.add(Embedding(vocab_size, embeded_vector_size, input_length=max_length,name=\"embedding\"))\n",
+ "model.add(Embedding(vocab_size, embeded_vector_size, input_shape=(max_length,),name=\"embedding\"))\n",
"model.add(Flatten())\n",
"model.add(Dense(1, activation='sigmoid'))"
]
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@@ -123,27 +132,94 @@
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": 8,
"metadata": {},
"outputs": [
+ {
+ "data": {
+ "text/html": [
+ "Model: \"sequential_1\"\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1mModel: \"sequential_1\"\u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n",
+ "┃ Layer (type) ┃ Output Shape ┃ Param # ┃\n",
+ "┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n",
+ "│ embedding (Embedding) │ (None, 4, 5) │ 150 │\n",
+ "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
+ "│ flatten (Flatten) │ (None, 20) │ 0 │\n",
+ "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
+ "│ dense (Dense) │ (None, 1) │ 21 │\n",
+ "└─────────────────────────────────┴────────────────────────┴───────────────┘\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n",
+ "┃\u001b[1m \u001b[0m\u001b[1mLayer (type) \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mOutput Shape \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1m Param #\u001b[0m\u001b[1m \u001b[0m┃\n",
+ "┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n",
+ "│ embedding (\u001b[38;5;33mEmbedding\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m4\u001b[0m, \u001b[38;5;34m5\u001b[0m) │ \u001b[38;5;34m150\u001b[0m │\n",
+ "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
+ "│ flatten (\u001b[38;5;33mFlatten\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m20\u001b[0m) │ \u001b[38;5;34m0\u001b[0m │\n",
+ "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
+ "│ dense (\u001b[38;5;33mDense\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m1\u001b[0m) │ \u001b[38;5;34m21\u001b[0m │\n",
+ "└─────────────────────────────────┴────────────────────────┴───────────────┘\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " Total params: 171 (684.00 B)\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1m Total params: \u001b[0m\u001b[38;5;34m171\u001b[0m (684.00 B)\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " Trainable params: 171 (684.00 B)\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1m Trainable params: \u001b[0m\u001b[38;5;34m171\u001b[0m (684.00 B)\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ " Non-trainable params: 0 (0.00 B)\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[1m Non-trainable params: \u001b[0m\u001b[38;5;34m0\u001b[0m (0.00 B)\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Model: \"sequential_1\"\n",
- "_________________________________________________________________\n",
- "Layer (type) Output Shape Param # \n",
- "=================================================================\n",
- "embedding (Embedding) (None, 4, 5) 150 \n",
- "_________________________________________________________________\n",
- "flatten_1 (Flatten) (None, 20) 0 \n",
- "_________________________________________________________________\n",
- "dense_1 (Dense) (None, 1) 21 \n",
- "=================================================================\n",
- "Total params: 171\n",
- "Trainable params: 171\n",
- "Non-trainable params: 0\n",
- "_________________________________________________________________\n",
"None\n"
]
}
@@ -155,7 +231,7 @@
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": 9,
"metadata": {
"scrolled": true
},
@@ -163,10 +239,10 @@
{
"data": {
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 26,
+ "execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
@@ -177,14 +253,14 @@
},
{
"cell_type": "code",
- "execution_count": 29,
+ "execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "1/1 [==============================] - 0s 1ms/step - loss: 0.6384 - accuracy: 1.0000\n"
+ "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 240ms/step - accuracy: 1.0000 - loss: 0.6310\n"
]
},
{
@@ -193,7 +269,7 @@
"1.0"
]
},
- "execution_count": 29,
+ "execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@@ -206,7 +282,7 @@
},
{
"cell_type": "code",
- "execution_count": 30,
+ "execution_count": 12,
"metadata": {},
"outputs": [
{
@@ -215,7 +291,7 @@
"30"
]
},
- "execution_count": 30,
+ "execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@@ -227,17 +303,17 @@
},
{
"cell_type": "code",
- "execution_count": 31,
+ "execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "array([-0.08330977, -0.06752131, -0.04629624, -0.00765801, -0.02024159],\n",
+ "array([-0.045216 , 0.00943187, 0.03090814, 0.05136584, -0.02863106],\n",
" dtype=float32)"
]
},
- "execution_count": 31,
+ "execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@@ -248,7 +324,7 @@
},
{
"cell_type": "code",
- "execution_count": 32,
+ "execution_count": 14,
"metadata": {
"scrolled": false
},
@@ -256,11 +332,11 @@
{
"data": {
"text/plain": [
- "array([-0.07935128, -0.08574004, 0.06615968, -0.02349528, 0.00917289],\n",
+ "array([-0.02916647, -0.02386854, -0.01521603, 0.0814022 , -0.02878025],\n",
" dtype=float32)"
]
},
- "execution_count": 32,
+ "execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
@@ -271,7 +347,7 @@
},
{
"cell_type": "code",
- "execution_count": 33,
+ "execution_count": 15,
"metadata": {
"scrolled": true
},
@@ -279,11 +355,11 @@
{
"data": {
"text/plain": [
- "array([ 0.0128377 , 0.03549778, 0.05134471, -0.07147218, 0.03261041],\n",
+ "array([ 0.01368184, 0.03296448, -0.02938928, -0.04986261, 0.03319566],\n",
" dtype=float32)"
]
},
- "execution_count": 33,
+ "execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
@@ -309,7 +385,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.8.5"
+ "version": "3.11.5"
}
},
"nbformat": 4,