2023-04-05 17:12:57 +02:00
{
"cells": [
{
2023-04-10 22:26:58 +02:00
"cell_type": "markdown",
"id": "0b7d591a",
2023-04-05 17:12:57 +02:00
"metadata": {},
"source": [
2023-04-10 22:26:58 +02:00
"\n",
" An example of the minimzer usage in tensorflow\n",
" the loss function is plotted and the result in terms of a line\n"
2023-04-05 17:12:57 +02:00
]
},
{
"cell_type": "code",
2023-04-11 18:27:30 +02:00
"execution_count": 1,
2023-04-05 17:12:57 +02:00
"id": "270932f3",
"metadata": {},
2023-04-11 18:27:30 +02:00
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2023-04-11 16:44:42.299418: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE4.1 SSE4.2 AVX AVX2 AVX512F AVX512_VNNI FMA\n",
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
"2023-04-11 16:44:42.360104: I tensorflow/core/util/port.cc:104] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.\n"
]
}
],
2023-04-05 17:12:57 +02:00
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import tensorflow as tf"
]
},
{
"cell_type": "code",
2023-04-11 18:27:30 +02:00
"execution_count": 2,
2023-04-05 17:12:57 +02:00
"id": "77cd99a8",
"metadata": {},
"outputs": [],
"source": [
"# Define the training data\n",
"train_X = np.asarray([3.3,4.4,5.5,6.71,6.93,4.168,9.779,6.182,7.59,2.167,\n",
" 7.042,10.791,5.313,7.997,5.654,9.27,3.1])\n",
"train_Y = np.asarray([1.7,2.76,2.09,3.19,1.694,1.573,3.366,2.596,2.53,1.221,\n",
" 2.827,3.465,1.65,2.904,2.42,2.94,1.3])\n"
]
},
{
"cell_type": "markdown",
"id": "f39cbcd9",
"metadata": {},
"source": [
"The input to the model is represented by the train_X \n",
"Y_train represents the target or the truth values for the training data\n",
"The model will recieve train_X and make predictions on the weights\n",
"The difference between these predictions and the actual target values\n",
"train_Y will be used to update the weights and minimize the loss function."
]
},
{
"cell_type": "code",
2023-04-11 18:27:30 +02:00
"execution_count": 3,
2023-04-05 17:12:57 +02:00
"id": "ed8449c3",
"metadata": {},
"outputs": [],
"source": [
"# Define the model to a simple linear regression with only one dense layer and\n",
"# no activation function for the first layer all train_X points are input\n",
"\n",
"# model = tf.keras.models.Sequential([\n",
"# tf.keras.layers.Dense(1, input_shape=[1])\n",
"#])"
]
},
{
"cell_type": "code",
2023-04-11 18:27:30 +02:00
"execution_count": 4,
2023-04-05 17:12:57 +02:00
"id": "71e072b4",
"metadata": {},
2023-04-11 18:27:30 +02:00
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2023-04-11 16:44:43.775141: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE4.1 SSE4.2 AVX AVX2 AVX512F AVX512_VNNI FMA\n",
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n"
]
}
],
2023-04-05 17:12:57 +02:00
"source": [
"# This model has 2 dense layers the first with relu activation\n",
"# and the 2nd layer has 1 output unit and uses the default\n",
"# linear activation function.\n",
"\n",
"model = tf.keras.models.Sequential([\n",
" tf.keras.layers.Dense(17, activation='relu',input_shape=[1]),\n",
" tf.keras.layers.Dense(1)\n",
"])"
]
},
{
"cell_type": "code",
2023-04-11 18:27:30 +02:00
"execution_count": 5,
2023-04-05 17:12:57 +02:00
"id": "5fabf184",
"metadata": {},
"outputs": [],
"source": [
"# different optimizer methods can be enabled\n",
"\n",
"model.compile(optimizer=tf.keras.optimizers.Adam(0.01), loss='mean_squared_error')\n",
"#model.compile(optimizer=tf.keras.optimizers.SGD(0.01), loss='mean_squared_error')\n",
"#model.compile(optimizer=tf.keras.optimizers.Adagrad(learning_rate=0.01), loss='mean_squared_error')\n",
"#model.compile(optimizer=tf.keras.optimizers.RMSprop(learning_rate=0.01), loss='mean_squared_error')\n",
"#model.compile(optimizer=tf.keras.optimizers.Ftrl(learning_rate=0.015), loss='mean_squared_error')"
]
},
{
"cell_type": "code",
2023-04-11 18:27:30 +02:00
"execution_count": 6,
2023-04-05 17:12:57 +02:00
"id": "22c4124f",
"metadata": {},
2023-04-11 18:27:30 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch 1/60\n",
"1/1 [==============================] - 0s 396ms/step - loss: 15.2606\n",
"Epoch 2/60\n",
"1/1 [==============================] - 0s 4ms/step - loss: 12.7440\n",
"Epoch 3/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 10.4745\n",
"Epoch 4/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 8.4519\n",
"Epoch 5/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 6.6738\n",
"Epoch 6/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 5.1356\n",
"Epoch 7/60\n",
"1/1 [==============================] - 0s 4ms/step - loss: 3.8306\n",
"Epoch 8/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 2.7499\n",
"Epoch 9/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 1.8823\n",
"Epoch 10/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 1.2142\n",
"Epoch 11/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.7292\n",
"Epoch 12/60\n",
"1/1 [==============================] - 0s 4ms/step - loss: 0.4087\n",
"Epoch 13/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2310\n",
"Epoch 14/60\n",
"1/1 [==============================] - 0s 4ms/step - loss: 0.1722\n",
"Epoch 15/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2060\n",
"Epoch 16/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.3049\n",
"Epoch 17/60\n",
"1/1 [==============================] - 0s 2ms/step - loss: 0.4419\n",
"Epoch 18/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.5909\n",
"Epoch 19/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.7296\n",
"Epoch 20/60\n",
"1/1 [==============================] - 0s 4ms/step - loss: 0.8423\n",
"Epoch 21/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.9194\n",
"Epoch 22/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.9578\n",
"Epoch 23/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.9579\n",
"Epoch 24/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.9233\n",
"Epoch 25/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.8606\n",
"Epoch 26/60\n",
"1/1 [==============================] - 0s 2ms/step - loss: 0.7777\n",
"Epoch 27/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.6828\n",
"Epoch 28/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.5839\n",
"Epoch 29/60\n",
"1/1 [==============================] - 0s 4ms/step - loss: 0.4879\n",
"Epoch 30/60\n",
"1/1 [==============================] - 0s 2ms/step - loss: 0.4003\n",
"Epoch 31/60\n",
"1/1 [==============================] - 0s 2ms/step - loss: 0.3253\n",
"Epoch 32/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2652\n",
"Epoch 33/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2208\n",
"Epoch 34/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.1917\n",
"Epoch 35/60\n",
"1/1 [==============================] - 0s 4ms/step - loss: 0.1766\n",
"Epoch 36/60\n",
"1/1 [==============================] - 0s 4ms/step - loss: 0.1731\n",
"Epoch 37/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.1785\n",
"Epoch 38/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.1899\n",
"Epoch 39/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2046\n",
"Epoch 40/60\n",
"1/1 [==============================] - 0s 4ms/step - loss: 0.2202\n",
"Epoch 41/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2345\n",
"Epoch 42/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2460\n",
"Epoch 43/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2537\n",
"Epoch 44/60\n",
"1/1 [==============================] - 0s 5ms/step - loss: 0.2572\n",
"Epoch 45/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2565\n",
"Epoch 46/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2520\n",
"Epoch 47/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2444\n",
"Epoch 48/60\n",
"1/1 [==============================] - 0s 4ms/step - loss: 0.2346\n",
"Epoch 49/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2234\n",
"Epoch 50/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.2119\n",
"Epoch 51/60\n",
"1/1 [==============================] - 0s 4ms/step - loss: 0.2010\n",
"Epoch 52/60\n",
"1/1 [==============================] - 0s 11ms/step - loss: 0.1912\n",
"Epoch 53/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.1831\n",
"Epoch 54/60\n",
"1/1 [==============================] - 0s 4ms/step - loss: 0.1771\n",
"Epoch 55/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.1730\n",
"Epoch 56/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.1709\n",
"Epoch 57/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.1705\n",
"Epoch 58/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.1713\n",
"Epoch 59/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.1730\n",
"Epoch 60/60\n",
"1/1 [==============================] - 0s 3ms/step - loss: 0.1751\n",
"{'verbose': 1, 'epochs': 60, 'steps': 1}\n"
]
}
],
2023-04-05 17:12:57 +02:00
"source": [
"# Train the model and access training parameters\n",
"history = model.fit(train_X, train_Y, epochs=60)\n",
"print(history.params)"
]
},
{
"cell_type": "code",
2023-04-11 18:27:30 +02:00
"execution_count": 7,
2023-04-05 17:12:57 +02:00
"id": "46615960",
"metadata": {},
2023-04-11 18:27:30 +02:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Weight matrix shape: (1, 17)\n",
"Bias vector shape: (17,)\n",
"[[-0.2720451 0.25746062 0.00145817 -0.14928943 -0.18011677 -0.38295865\n",
" -0.10688066 -0.08276322 -0.06117761 -0.415354 0.21152566 -0.015845\n",
" -0.22856292 0.25203183 0.29251993 -0.08234903 0.6508041 ]]\n"
]
}
],
2023-04-05 17:12:57 +02:00
"source": [
"# Get the weights of the Dense layer\n",
"weights = model.layers[0].get_weights()\n",
"# Print the weight matrix and bias vector\n",
"print('Weight matrix shape:', weights[0].shape)\n",
"print('Bias vector shape:', weights[1].shape)\n",
"print (weights[0])"
]
},
{
"cell_type": "code",
2023-04-11 18:27:30 +02:00
"execution_count": 8,
2023-04-05 17:12:57 +02:00
"id": "da12fc5b",
"metadata": {},
2023-04-11 18:27:30 +02:00
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjMAAAHFCAYAAAAHcXhbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAABDe0lEQVR4nO3deXxU9b3/8feZmWSykAxZyAZJWGQPIAIiggouKCpu1apVhLb316K4cG2tUtuCXm0q/ZXalh/0alW0VrS9V7jcWhesLCpadkFE1ggBEkKA7MkkmTm/P8IMjAmYZZIzk7yej8d5JHPOTPLJl8C8+W7HME3TFAAAQJiyWV0AAABAWxBmAABAWCPMAACAsEaYAQAAYY0wAwAAwhphBgAAhDXCDAAACGuEGQAAENYIMwAAIKwRZoAuYMmSJTIMQxs3brS6l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iSdLbb78tSZo1a1arv8eZWtKW56pRkg4cOBCUmoDOjjADQCdPnpRpmkpPT290LSMjQ5L8w0i///3v9eijj2r58uWaNGmSEhMTddNNN2nPnj2SGoaE/vnPf+rqq6/W/PnzdcEFF6hHjx568MEHVV5e3qx6RowYodGjR/sP35t7ayQlJQU89g0P+ULYsWPHZLfblZaW1urvcaaWtGVzawRwboQZAEpISJDNZlNBQUGja76JqL7VRbGxsXriiSf05ZdfqrCwUIsXL9ann36qqVOn+l+TnZ2tF154QYWFhdq1a5f+/d//XYsWLdIjjzzSpjqjoqIkSW63O+D818NBS/To0UMej0eFhYVtqs2nJW0JIDgIMwAUGxursWPH6s033wzoDfB6vXr11VfVq1cvDRgwoNHrUlNTNWPGDN15553atWuXqqqqGj1nwIAB+tnPfqZhw4Zp8+bNbaozNTVVUVFR2rZtW8D5//mf/2n115wyZYokafHixed8ntPpbFZPSWvbEkDrsZoJ6EI++OAD/wqdM1177bXKzc3VVVddpUmTJunHP/6xIiMjtWjRIn3++edaunSpDMOQJI0dO1bXX3+9hg8froSEBO3cuVN//vOfNW7cOMXExGjbtm26//77ddttt6l///6KjIzUBx98oG3btumxxx5rU/2GYejuu+/Wiy++qH79+mnEiBFav369XnvttVZ/zUsuuUTTpk3TU089paNHj+r666+X0+nUli1bFBMTowceeECSNGzYML3++ut644031LdvX0VFRWnYsGFNfs3mtiWA4CDMAF3Io48+2uT5vLw8XXbZZfrggw80d+5czZgxQ16vVyNGjNCKFSt0/fXX+597+eWXa8WKFfrtb3+rqqoq9ezZU/fcc48ef/xxSVJaWpr69eunRYsWKT8/X4ZhqG/fvvrNb37jDwZt8Zvf/EaSNH/+fFVUVOjyyy/X3//+d/++L62xZMkSXXDBBXrhhRe0ZMkSRUdHa8iQIfrpT3/qf84TTzyhgoIC/Z//839UXl6u7OzsJoOhpGa3JYDgMEzTNK0uAgAAoLWYMwMAAMIaYQYAAIQ1wgwAAAhrloaZtWvXaurUqcrIyJBhGFq+fHmj5+zcuVM33HC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JAAAsRZhpoyxuOAkAgKUIM23EMBMAANYizLRRFhvnAQBgKcJMG/l6ZgrLalRT57G4GgAAuh7CTBslxUYqNtIu05QOnay2uhwAALocwkwbGYahrCTfUBOTgAEA6GiEmSDwLc9mEjAAAB2PMBMErGgCAMA6hJkg4O7ZAABYhzATBFmJbJwHAIBVLA0za9eu1dSpU5WRkSHDMLR8+fKzPveHP/yhDMPQs88+22H1NVf2qb1m8k9Wy+s1La4GAICuxdIwU1lZqREjRmjhwoXnfN7y5cv1r3/9SxkZGR1UWct
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"1/1 [==============================] - 0s 61ms/step\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGdCAYAAADAAnMpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAABEP0lEQVR4nO3deXxM5/4H8M8YkYUsTSqbRCd2opYKtykhsZWoyw23evkVt7ropUXqlthKi1CthlJbLS3VTVJV1C4RLbU0QYk9IdLJja0JIdvk/P6YZuqYGckkM3Nm5nzer5eXznfOzPlGUvPxPM95jkIQBAFEREREEqkldQNEREQkbwwjREREJCmGESIiIpIUwwgRERFJimGEiIiIJMUwQkRERJJiGCEiIiJJMYwQERGRpGpL3UBVlJeX4/fff4e7uzsUCoXU7RAREVEVCIKAO3fuIDAwELVqGR//sIsw8vvvvyM4OFjqNoiIiKgasrOzERQUZPR5uwgj7u7uALRfjIeHh8TdEBERUVUUFBQgODhY9zlujF2EkYqpGQ8PD4YRIiIiO1PZEgsuYCUiIiJJMYwQERGRpBhGiIiISFJ2sWakKgRBQFlZGTQajdStkI1TKpWoXbs2LxMnIrIRDhFGSkpKoFarce/ePalbITvh5uaGgIAA1KlTR+pWiIh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5ciQUCgUUCgWcnJzQqFEjTJw4EYWFhRY976JFi3Q30asMAwQRkTT+uFcC1eRt2JPxP11t85jOmPn
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
2023-04-05 17:12:57 +02:00
"source": [
"# Plot the loss function\n",
"plt.plot(history.history['loss'])\n",
"plt.title(\"Loss Function\")\n",
"plt.xlabel(\"Epoch\")\n",
"plt.ylabel(\"Loss\")\n",
"plt.show()\n",
"\n",
"# Plot the input data and the predicted values\n",
"plt.plot(train_X, train_Y, 'ro', label=\"Original Data\")\n",
"plt.plot(train_X, model.predict(train_X), label=\"Predicted\")\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "60417d5f",
"metadata": {},
"outputs": [],
"source": []
}
],
"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.8.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}