{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"Deep Learning con Keras - Esercizio 1.ipynb","provenance":[],"collapsed_sections":[],"authorship_tag":"ABX9TyNcqEDLKMEgJjvdqpdi5Yrn"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"},"accelerator":"GPU"},"cells":[{"cell_type":"markdown","source":["# Esercizio: classificazione del set di dati CIFAR 10\n","\n","CIFAR 10 è un insieme di 60.000 immagini 32x32 a colori, di cui 50.000 per l'addestramento e 10.000 per il test. Ogni immagine può appartenere ad una di 10 possibili categorie: \n","\n","* 0 \tairplane\n","* 1 \tautomobile\n","* 2 \tbird\n","* 3 \tcat\n","* 4 \tdeer\n","* 5 \tdog\n","* 6 \tfrog\n","* 7 \thorse\n","* 8 \tship\n","* 9 \ttruck"],"metadata":{"id":"Xh3-lMtQ8Fca"}},{"cell_type":"markdown","source":["## Preparazione dati"],"metadata":{"id":"ZuE5CLEw_Elt"}},{"cell_type":"code","source":["import numpy as np\n","import tensorflow as tf\n","import matplotlib.pyplot as plt"],"metadata":{"id":"t2dr0HjTyS6n","executionInfo":{"status":"ok","timestamp":1647971643089,"user_tz":-60,"elapsed":504,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}}},"execution_count":3,"outputs":[]},{"cell_type":"code","source":["# Caricamento dell'insieme di dati.\n","\n","(cifar_train_images, cifar_train_labels), (cifar_test_images, cifar_test_labels) = tf.keras.datasets.cifar10.load_data()"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"qgacOOI48rqa","executionInfo":{"status":"ok","timestamp":1647971657697,"user_tz":-60,"elapsed":14088,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"3010d034-d7c1-4607-cb7e-0a2583648afc"},"execution_count":4,"outputs":[{"output_type":"stream","name":"stdout","text":["Downloading data from https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz\n","170500096/170498071 [==============================] - 11s 0us/step\n","170508288/170498071 [==============================] - 11s 0us/step\n"]}]},{"cell_type":"code","source":["# cifar_train_images è un array a 4 dimensioni. L'ultima dimensione è il canale colore (Red, Green e Blue)\n","\n","cifar_train_images.shape"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"B6wVoe-p8zT1","executionInfo":{"status":"ok","timestamp":1647971657702,"user_tz":-60,"elapsed":54,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"075a0902-c9a6-46f8-eb4b-f92ba40c6919"},"execution_count":5,"outputs":[{"output_type":"execute_result","data":{"text/plain":["(50000, 32, 32, 3)"]},"metadata":{},"execution_count":5}]},{"cell_type":"code","source":["cifar_train_images[0]"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"SEaDZKT3Acpa","executionInfo":{"status":"ok","timestamp":1647971657707,"user_tz":-60,"elapsed":46,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"a94b4966-eca3-4b59-b1b9-65cf19b07860"},"execution_count":6,"outputs":[{"output_type":"execute_result","data":{"text/plain":["array([[[ 59, 62, 63],\n"," [ 43, 46, 45],\n"," [ 50, 48, 43],\n"," ...,\n"," [158, 132, 108],\n"," [152, 125, 102],\n"," [148, 124, 103]],\n","\n"," [[ 16, 20, 20],\n"," [ 0, 0, 0],\n"," [ 18, 8, 0],\n"," ...,\n"," [123, 88, 55],\n"," [119, 83, 50],\n"," [122, 87, 57]],\n","\n"," [[ 25, 24, 21],\n"," [ 16, 7, 0],\n"," [ 49, 27, 8],\n"," ...,\n"," [118, 84, 50],\n"," [120, 84, 50],\n"," [109, 73, 42]],\n","\n"," ...,\n","\n"," [[208, 170, 96],\n"," [201, 153, 34],\n"," [198, 161, 26],\n"," ...,\n"," [160, 133, 70],\n"," [ 56, 31, 7],\n"," [ 53, 34, 20]],\n","\n"," [[180, 139, 96],\n"," [173, 123, 42],\n"," [186, 144, 30],\n"," ...,\n"," [184, 148, 94],\n"," [ 97, 62, 34],\n"," [ 83, 53, 34]],\n","\n"," [[177, 144, 116],\n"," [168, 129, 94],\n"," [179, 142, 87],\n"," ...,\n"," [216, 184, 140],\n"," [151, 118, 84],\n"," [123, 92, 72]]], dtype=uint8)"]},"metadata":{},"execution_count":6}]},{"cell_type":"code","source":["cifar_train_images_ok = cifar_train_images / 255.0\n","cifar_test_images_ok = cifar_test_images / 255.0"],"metadata":{"id":"2csyOh8EAgDd","executionInfo":{"status":"ok","timestamp":1647971658277,"user_tz":-60,"elapsed":598,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}}},"execution_count":7,"outputs":[]},{"cell_type":"code","source":["plt.imshow(cifar_train_images_ok[0])"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":283},"id":"adpt4PUx-2A8","executionInfo":{"status":"ok","timestamp":1647971658817,"user_tz":-60,"elapsed":570,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"81a2e998-858f-4569-8fa5-c0a9271cace7"},"execution_count":8,"outputs":[{"output_type":"execute_result","data":{"text/plain":[""]},"metadata":{},"execution_count":8},{"output_type":"display_data","data":{"text/plain":["
"],"image/png":"iVBORw0KGgoAAAANSUhEUg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oGAXIhEU7EIkgoJdiET4vyrWWZ/xQ9u6AAAAAElFTkSuQmCC\n"},"metadata":{"needs_background":"light"}}]},{"cell_type":"code","source":["# cifar_train_labels contiene le etichette numeriche delle singole immagini.\n","# Ad esempio l'etichetta dell'immagine 0 è 6 (frog). Non è particolarmente\n","# importante, ma in realtà ogni elemento di cifar_train_labels non è un valore\n","# da 0 a 9, ma un vettore con un solo elemento, che è il valore da 0 a 9 cercato.\n","\n","cifar_train_labels[0]"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"b1dxkNOw830C","executionInfo":{"status":"ok","timestamp":1647971658823,"user_tz":-60,"elapsed":63,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"b122ef17-663a-4aa0-e107-779128df70f0"},"execution_count":9,"outputs":[{"output_type":"execute_result","data":{"text/plain":["array([6], dtype=uint8)"]},"metadata":{},"execution_count":9}]},{"cell_type":"code","source":["# One Hot Ecoding delle etichette\n","\n","cifar_train_labels_ok = tf.keras.utils.to_categorical(cifar_train_labels)\n","cifar_test_labels_ok = tf.keras.utils.to_categorical(cifar_test_labels)\n","\n","cifar_train_labels_ok[0]"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"YSroErMk9aPp","executionInfo":{"status":"ok","timestamp":1647971658828,"user_tz":-60,"elapsed":58,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"f699b106-afe6-4ba2-f8b0-ddb13998de59"},"execution_count":10,"outputs":[{"output_type":"execute_result","data":{"text/plain":["array([0., 0., 0., 0., 0., 0., 1., 0., 0., 0.], dtype=float32)"]},"metadata":{},"execution_count":10}]},{"cell_type":"code","source":["# Creiamo anche un vettore di nomi per poter facilmente associare l'etichetta\n","# numerica al corrispondente significato\n","\n","cifar_class_names = ['airplane','automobile','bird','cat','deer','dog','frog','horse','ship','truck']\n","\n","cifar_class_names[cifar_train_labels[0, 0]]"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":35},"id":"M-r0rmeQAY7q","executionInfo":{"status":"ok","timestamp":1647971658835,"user_tz":-60,"elapsed":54,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"4a270c37-e437-4070-cac9-7abdc73178d0"},"execution_count":11,"outputs":[{"output_type":"execute_result","data":{"text/plain":["'frog'"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"string"}},"metadata":{},"execution_count":11}]},{"cell_type":"markdown","source":["## Rete neurale"],"metadata":{"id":"0WTaVfOH_Gqv"}},{"cell_type":"code","source":["# Possibile soluzione. Notare che, nonostante il numero molto alto di strati intermedi\n","# (e la conseguenza lentezza nell'addestramento) le prestazioni della rete sono molto\n","# inferiori a quelle che si sono ottenute con MNIST.\n","\n","# ATTENZIONE: esistono metodi migliori che vedremo nei prossimi seminari\n","\n","network_cifar = tf.keras.models.Sequential([\n"," tf.keras.layers.Flatten(input_shape=(32, 32, 3)),\n"," tf.keras.layers.Dense(512, activation='relu'),\n"," tf.keras.layers.Dense(512, activation='relu'),\n"," tf.keras.layers.Dense(10, activation='softmax')\n","])\n","network_cifar.summary()"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"p3tJDNN6_IYL","executionInfo":{"status":"ok","timestamp":1647971673670,"user_tz":-60,"elapsed":3982,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"0d26cf9c-69b4-4df1-fb78-9f70a5d6fa9e"},"execution_count":12,"outputs":[{"output_type":"stream","name":"stdout","text":["Model: \"sequential\"\n","_________________________________________________________________\n"," Layer (type) Output Shape Param # \n","=================================================================\n"," flatten (Flatten) (None, 3072) 0 \n"," \n"," dense (Dense) (None, 512) 1573376 \n"," \n"," dense_1 (Dense) (None, 512) 262656 \n"," \n"," dense_2 (Dense) (None, 10) 5130 \n"," \n","=================================================================\n","Total params: 1,841,162\n","Trainable params: 1,841,162\n","Non-trainable params: 0\n","_________________________________________________________________\n"]}]},{"cell_type":"code","source":["network_cifar.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])\n","history_cifar = network_cifar.fit(cifar_train_images_ok, cifar_train_labels_ok, epochs=30, batch_size=128)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"OQgnt5xYEBRZ","executionInfo":{"status":"ok","timestamp":1647971804081,"user_tz":-60,"elapsed":76421,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"a9a35231-d28f-48de-befa-97c0e89d9d3d"},"execution_count":13,"outputs":[{"output_type":"stream","name":"stdout","text":["Epoch 1/30\n","391/391 [==============================] - 5s 6ms/step - loss: 1.8645 - accuracy: 0.3302\n","Epoch 2/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.6604 - accuracy: 0.4051\n","Epoch 3/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.5669 - accuracy: 0.4398\n","Epoch 4/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.5182 - accuracy: 0.4584\n","Epoch 5/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.4688 - accuracy: 0.4778\n","Epoch 6/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.4385 - accuracy: 0.4861\n","Epoch 7/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.4029 - accuracy: 0.5008\n","Epoch 8/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.3783 - accuracy: 0.5090\n","Epoch 9/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.3523 - accuracy: 0.5188\n","Epoch 10/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.3228 - accuracy: 0.5281\n","Epoch 11/30\n","391/391 [==============================] - 3s 7ms/step - loss: 1.3015 - accuracy: 0.5358\n","Epoch 12/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.2797 - accuracy: 0.5458\n","Epoch 13/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.2583 - accuracy: 0.5512\n","Epoch 14/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.2336 - accuracy: 0.5626\n","Epoch 15/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.2128 - accuracy: 0.5684\n","Epoch 16/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.1997 - accuracy: 0.5712\n","Epoch 17/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.1785 - accuracy: 0.5801\n","Epoch 18/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.1577 - accuracy: 0.5870\n","Epoch 19/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.1413 - accuracy: 0.5925\n","Epoch 20/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.1238 - accuracy: 0.5994\n","Epoch 21/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.1008 - accuracy: 0.6051\n","Epoch 22/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.0915 - accuracy: 0.6089\n","Epoch 23/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.0749 - accuracy: 0.6164\n","Epoch 24/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.0564 - accuracy: 0.6228\n","Epoch 25/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.0359 - accuracy: 0.6298\n","Epoch 26/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.0293 - accuracy: 0.6295\n","Epoch 27/30\n","391/391 [==============================] - 2s 6ms/step - loss: 1.0135 - accuracy: 0.6359\n","Epoch 28/30\n","391/391 [==============================] - 2s 6ms/step - loss: 0.9976 - accuracy: 0.6424\n","Epoch 29/30\n","391/391 [==============================] - 2s 6ms/step - loss: 0.9826 - accuracy: 0.6505\n","Epoch 30/30\n","391/391 [==============================] - 2s 6ms/step - loss: 0.9748 - accuracy: 0.6503\n"]}]},{"cell_type":"code","source":["# La situazione è ancora peggiore se guardiamo all'accuratezza sull'insieme di test, che è circa\n","# del 50%. Siamo in una situazione con un notevole overfitting.\n","\n","network_cifar.evaluate(cifar_test_images_ok, cifar_test_labels_ok)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"Qb4zqNfCDtSa","executionInfo":{"status":"ok","timestamp":1647971845206,"user_tz":-60,"elapsed":1042,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"8e9b061a-30a4-4e80-db55-59b662b92ce9"},"execution_count":14,"outputs":[{"output_type":"stream","name":"stdout","text":["313/313 [==============================] - 1s 3ms/step - loss: 1.4447 - accuracy: 0.5225\n"]},{"output_type":"execute_result","data":{"text/plain":["[1.4447178840637207, 0.5224999785423279]"]},"metadata":{},"execution_count":14}]},{"cell_type":"code","source":["# Questo è l'elenco delle immagini (dell'insieme di addestramento) per cui la rete sbaglia\n","\n","cifar_predictions = network_cifar.predict(cifar_train_images_ok)\n","np.where([ np.argmax(x) for x in cifar_predictions] != cifar_train_labels.flatten())"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"4py-FmCsEDdJ","executionInfo":{"status":"ok","timestamp":1647971873982,"user_tz":-60,"elapsed":4597,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"e0d5ee3c-45f7-455c-f304-9cd32d83ddc9"},"execution_count":15,"outputs":[{"output_type":"execute_result","data":{"text/plain":["(array([ 3, 9, 15, ..., 49994, 49995, 49999]),)"]},"metadata":{},"execution_count":15}]},{"cell_type":"code","source":["# Controlliamo ad esempio l'immagine 15\n","\n","print(\"Predizione: \", cifar_class_names[np.argmax(cifar_predictions[155])])\n","print(\"Valore effettivo: \", cifar_class_names[cifar_train_labels[15, 0]])\n","\n","plt.imshow(cifar_train_images[15])"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":318},"id":"6oAtihIjEWiu","executionInfo":{"status":"ok","timestamp":1647971877009,"user_tz":-60,"elapsed":32,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"a896cd61-f7c2-458c-877c-c855e027c7b6"},"execution_count":16,"outputs":[{"output_type":"stream","name":"stdout","text":["Predizione: ship\n","Valore effettivo: truck\n"]},{"output_type":"execute_result","data":{"text/plain":[""]},"metadata":{},"execution_count":16},{"output_type":"display_data","data":{"text/plain":["
"],"image/png":"iVBORw0KGgoAAAANSUhEUgAAAPsAAAD5CAYAAADhukOtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAcOklEQVR4nO2da4yc53Xf/2fueyOXy13eaVE3uxXcSnZZwUWMwE2QQHECyAYKw/5g6IMRBkUM1ED6QVCB2gWKwilqG/5QuKBrIUrh+lJfYiEwmrhqUCMIIptyZN0oRxJFWqQoXve+O7Mz855+mBFCCc//7HJ2d5bW8/8BBGefs8/7nnnmPfPOPv8555i7Qwjxzqe00w4IIYaDgl2ITFCwC5EJCnYhMkHBLkQmKNiFyITKZiab2QM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AA/3Hz8M4I93yI/PAfi3Q16PgwDe3388AeDvAdwz7DUJ/BjqmqBXJHa8/7gK4EkAHwDwbQAf74//NwD/+maOuxN39vsBvOzuZ7xXevqbAB7cAT92DHf/MYDrbxt+EL3CncCQCngSP4aOu19095/1Hy+iVxzlMIa8JoEfQ8V7bHmR150I9sMAXrvh550sVukA/tLMnjKzEzvkw5vsd/eL/cdvAOCF0refT5vZM/2P+dv+58SNmNkx9OonPIkdXJO3+QEMeU22o8hr7ht0H3T39wP4HQB/aGa/vtMOAb13dsRdfreTrwC4E70eARcBfGFYJzazcQDfBfAZd39LddJhrknCj6GviW+iyCtjJ4L9AoCjN/xMi1VuN+5+of//ZQDfx85W3rlkZgcBoP//5Z1wwt0v9S+0AsBXMaQ1MbMqegH2dXf/Xn946GuS8mOn1qR/7psu8srYiWD/KYC7+zuLNQAfB/D4sJ0wszEzm3jzMYDfBvBcPGtbeRy9wp3ADhbwfDO4+nwUQ1gTMzP0ahiedvcv3mAa6powP4a9JttW5HVYO4xv2238MHo7na8A+Hc75MMd6CkBPwfw/DD9APAN9D4OttH72+tT6PXMewLASwD+D4CpHfLjfwB4FsAz6AXbwSH48UH0PqI/A+Dp/r8PD3tNAj+GuiYA/il6RVyfQe+N5d/fcM3+BMDLAP4XgPrNHFffoBMiE3LfoBMiGxTsQmSCgl2ITFCwC5EJCnYhMkHBLkQmKNiFyAQFuxCZ8P8B1aCvKd2BFQUAAAAASUVORK5CYII=\n"},"metadata":{"needs_background":"light"}}]},{"cell_type":"code","source":["# Ripetiamo l'addestramento con un insieme di validazione, in modo da controllare\n","# come evolve l'overfitting nel corso delle epoche. Questa volta lasciamo\n","# selezionare a TensorFlow i dati da usare per la validazione, aggiungendo il\n","# parametro validation_split = 0.2, che lo istruisce a utilizzare il 10% dei\n","# dati per la validazione e il resto per il training.\n","\n","network_cifar2 = tf.keras.models.Sequential([\n"," tf.keras.layers.Flatten(input_shape=(32, 32, 3)),\n"," tf.keras.layers.Dense(512, activation='relu'),\n"," tf.keras.layers.Dense(512, activation='relu'),\n"," tf.keras.layers.Dense(10, activation='softmax')\n","])\n","network_cifar2.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])\n","network_cifar2.fit(cifar_train_images_ok, cifar_train_labels_ok, epochs=30, batch_size=128, validation_split = 0.1)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"OCHYxBoMFOQj","executionInfo":{"status":"ok","timestamp":1647971957127,"user_tz":-60,"elapsed":73088,"user":{"displayName":"Gianluca Amato","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GhEmlMukD8qDnxG1PlDxK7Dzm1rjUKZSz0BhiJc9w=s64","userId":"18269286707108730791"}},"outputId":"ac6e5d87-d0bb-4804-cf2c-0ef8700499a4"},"execution_count":17,"outputs":[{"output_type":"stream","name":"stdout","text":["Epoch 1/30\n","352/352 [==============================] - 3s 8ms/step - loss: 1.9154 - accuracy: 0.3144 - val_loss: 1.7768 - val_accuracy: 0.3658\n","Epoch 2/30\n","352/352 [==============================] - 2s 7ms/step - loss: 1.6853 - accuracy: 0.3977 - val_loss: 1.6789 - val_accuracy: 0.4084\n","Epoch 3/30\n","352/352 [==============================] - 2s 7ms/step - loss: 1.5999 - accuracy: 0.4304 - val_loss: 1.5903 - val_accuracy: 0.4316\n","Epoch 4/30\n","352/352 [==============================] - 2s 7ms/step - loss: 1.5478 - accuracy: 0.4484 - val_loss: 1.5835 - val_accuracy: 0.4386\n","Epoch 5/30\n","352/352 [==============================] - 2s 6ms/step - loss: 1.4964 - accuracy: 0.4651 - val_loss: 1.5170 - val_accuracy: 0.4552\n","Epoch 6/30\n","352/352 [==============================] - 2s 7ms/step - loss: 1.4611 - accuracy: 0.4789 - val_loss: 1.4934 - val_accuracy: 0.4720\n","Epoch 7/30\n","352/352 [==============================] - 2s 7ms/step - loss: 1.4298 - accuracy: 0.4895 - val_loss: 1.4717 - val_accuracy: 0.4746\n","Epoch 8/30\n","352/352 [==============================] - 2s 7ms/step - loss: 1.4008 - accuracy: 0.5010 - val_loss: 1.4467 - val_accuracy: 0.4862\n","Epoch 9/30\n","352/352 [==============================] - 2s 6ms/step - loss: 1.3723 - accuracy: 0.5097 - val_loss: 1.4413 - val_accuracy: 0.4902\n","Epoch 10/30\n","352/352 [==============================] - 2s 6ms/step - loss: 1.3409 - accuracy: 0.5206 - val_loss: 1.4360 - val_accuracy: 0.4990\n","Epoch 11/30\n","352/352 [==============================] - 2s 7ms/step - loss: 1.3202 - accuracy: 0.5284 - val_loss: 1.4405 - val_accuracy: 0.4896\n","Epoch 12/30\n","352/352 [==============================] - 2s 6ms/step - loss: 1.2889 - accuracy: 0.5417 - val_loss: 1.4307 - val_accuracy: 0.4950\n","Epoch 13/30\n","352/352 [==============================] - 2s 6ms/step - loss: 1.2664 - accuracy: 0.5485 - val_loss: 1.4146 - val_accuracy: 0.5076\n","Epoch 14/30\n","352/352 [==============================] - 2s 6ms/step - loss: 1.2577 - accuracy: 0.5540 - val_loss: 1.3823 - val_accuracy: 0.5146\n","Epoch 15/30\n","352/352 [==============================] - 2s 6ms/step - loss: 1.2220 - accuracy: 0.5634 - val_loss: 1.3980 - val_accuracy: 0.5186\n","Epoch 16/30\n","352/352 [==============================] - 2s 7ms/step - loss: 1.2106 - accuracy: 0.5686 - val_loss: 1.3869 - val_accuracy: 0.5258\n","Epoch 17/30\n","352/352 [==============================] - 2s 6ms/step - loss: 1.1831 - accuracy: 0.5793 - val_loss: 1.4099 - val_accuracy: 0.5096\n","Epoch 18/30\n","352/352 [==============================] - 2s 6ms/step - loss: 1.1638 - accuracy: 0.5866 - val_loss: 1.3931 - val_accuracy: 0.5174\n","Epoch 19/30\n","352/352 [==============================] - 2s 6ms/step - loss: 1.1395 - accuracy: 0.5941 - val_loss: 1.4108 - val_accuracy: 0.5156\n","Epoch 20/30\n","352/352 [==============================] - 2s 7ms/step - loss: 1.1227 - accuracy: 0.6002 - val_loss: 1.3865 - val_accuracy: 0.5252\n","Epoch 21/30\n","352/352 [==============================] - 2s 6ms/step - loss: 1.1009 - accuracy: 0.6104 - val_loss: 1.4171 - val_accuracy: 0.5164\n","Epoch 22/30\n","352/352 [==============================] - 3s 8ms/step - loss: 1.0747 - accuracy: 0.6175 - val_loss: 1.4204 - val_accuracy: 0.5092\n","Epoch 23/30\n","352/352 [==============================] - 2s 6ms/step - loss: 1.0606 - accuracy: 0.6226 - val_loss: 1.4295 - val_accuracy: 0.5140\n","Epoch 24/30\n","352/352 [==============================] - 2s 7ms/step - loss: 1.0477 - accuracy: 0.6268 - val_loss: 1.4004 - val_accuracy: 0.5302\n","Epoch 25/30\n","352/352 [==============================] - 2s 7ms/step - loss: 1.0336 - accuracy: 0.6335 - val_loss: 1.4136 - val_accuracy: 0.5228\n","Epoch 26/30\n","352/352 [==============================] - 2s 7ms/step - loss: 1.0149 - accuracy: 0.6376 - val_loss: 1.4454 - val_accuracy: 0.5148\n","Epoch 27/30\n","352/352 [==============================] - 2s 7ms/step - loss: 0.9970 - accuracy: 0.6431 - val_loss: 1.4573 - val_accuracy: 0.5118\n","Epoch 28/30\n","352/352 [==============================] - 2s 7ms/step - loss: 0.9777 - accuracy: 0.6507 - val_loss: 1.4626 - val_accuracy: 0.5234\n","Epoch 29/30\n","352/352 [==============================] - 2s 7ms/step - loss: 0.9640 - accuracy: 0.6580 - val_loss: 1.4598 - val_accuracy: 0.5206\n","Epoch 30/30\n","352/352 [==============================] - 2s 6ms/step - loss: 0.9510 - accuracy: 0.6609 - val_loss: 1.4892 - val_accuracy: 0.5176\n"]},{"output_type":"execute_result","data":{"text/plain":[""]},"metadata":{},"execution_count":17}]}]}