Skip to content

Instantly share code, notes, and snippets.

@tejuafonja
Created March 7, 2019 03:41
Show Gist options
  • Save tejuafonja/3fe1998d159d8d07225dc70be5c5468f to your computer and use it in GitHub Desktop.
Save tejuafonja/3fe1998d159d8d07225dc70be5c5468f to your computer and use it in GitHub Desktop.
Colab1-for-deeplearn.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Colab1-for-deeplearn.ipynb",
"version": "0.3.2",
"provenance": [],
"toc_visible": true,
"include_colab_link": true
},
"kernelspec": {
"name": "python2",
"display_name": "Python 2"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/Tejaf/3fe1998d159d8d07225dc70be5c5468f/colab1-for-deeplearn.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"metadata": {
"id": "ZIAkIlfmCe1B",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"# The Hello World of Deep Learning with Neural Networks"
]
},
{
"metadata": {
"id": "fA93WUy1zzWf",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"Like every first app you should start with something super simple that shows the overall scaffolding for how your code works. \n",
"\n",
"In the case of creating neural networks, the sample I like to use is one where it learns the relationship between two numbers. So, for example, if you were writing code for a function like this, you already know the 'rules' -- \n",
"\n",
"\n",
"```\n",
"float hw_function(float x){\n",
" float y = (2 * x) - 1;\n",
" return y;\n",
"}\n",
"```\n",
"\n",
"So how would you train a neural network to do the equivalent task? Using data! By feeding it with a set of Xs, and a set of Ys, it should be able to figure out the relationship between them. \n",
"\n",
"This is obviously a very different paradigm than what you might be used to, so let's step through it piece by piece.\n"
]
},
{
"metadata": {
"id": "DzbtdRcZDO9B",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"## Imports\n",
"\n",
"Let's start with our imports. Here we are importing TensorFlow and calling it tf for ease of use.\n",
"\n",
"We then import a library called numpy, which helps us to represent our data as lists easily and quickly.\n",
"\n",
"The framework for defining a neural network as a set of Sequential layers is called keras, so we import that too."
]
},
{
"metadata": {
"id": "X9uIpOS2zx7k",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"import tensorflow as tf\n",
"import numpy as np\n",
"from tensorflow import keras"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "wwJGmDrQ0EoB",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"## Define and Compile the Neural Network\n",
"\n",
"Next we will create the simplest possible neural network. It has 1 layer, and that layer has 1 neuron, and the input shape to it is just 1 value."
]
},
{
"metadata": {
"id": "kQFAr_xo0M4T",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 89
},
"outputId": "fa61ecf5-9fc9-4931-c13c-cb866ef76ca8"
},
"cell_type": "code",
"source": [
"model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])"
],
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Colocations handled automatically by placer.\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "KhjZjZ-c0Ok9",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"Now we compile our Neural Network. When we do so, we have to specify 2 functions, a loss and an optimizer.\n",
"\n",
"If you've seen lots of math for machine learning, here's where it's usually used, but in this case it's nicely encapsulated in functions for you. But what happens here -- let's explain...\n",
"\n",
"We know that in our function, the relationship between the numbers is y=2x-1. \n",
"\n",
"When the computer is trying to 'learn' that, it makes a guess...maybe y=10x+10. The LOSS function measures the guessed answers against the known correct answers and measures how well or how badly it did.\n",
"\n",
"It then uses the OPTIMIZER function to make another guess. Based on how the loss function went, it will try to minimize the loss. At that point maybe it will come up with somehting like y=5x+5, which, while still pretty bad, is closer to the correct result (i.e. the loss is lower)\n",
"\n",
"It will repeat this for the number of EPOCHS which you will see shortly. But first, here's how we tell it to use 'MEAN SQUARED ERROR' for the loss and 'STOCHASTIC GRADIENT DESCENT' for the optimizer. You don't need to understand the math for these yet, but you can see that they work! :)\n",
"\n",
"Over time you will learn the different and appropriate loss and optimizer functions for different scenarios. \n"
]
},
{
"metadata": {
"id": "m8YQN1H41L-Y",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 89
},
"outputId": "54d4080d-c26a-401d-cb51-d0cf322aea5e"
},
"cell_type": "code",
"source": [
"model.compile(optimizer='sgd', loss='mean_squared_error')"
],
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/python/keras/utils/losses_utils.py:170: to_float (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.cast instead.\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "5QyOUhFw1OUX",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"## Providing the Data\n",
"\n",
"Next up we'll feed in some data. In this case we are taking 6 xs and 6ys. You can see that the relationship between these is that y=2x-1, so where x = -1, y=-3 etc. etc. \n",
"\n",
"A python library called 'Numpy' provides lots of array type data structures that are a defacto standard way of doing it. We declare that we want to use these by specifying the values asn an np.array[]"
]
},
{
"metadata": {
"id": "4Dxk4q-jzEy4",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)\n",
"ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "n_YcWRElnM_b",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"# Training the Neural Network"
]
},
{
"metadata": {
"id": "c-Jk4dG91dvD",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"The process of training the neural network, where it 'learns' the relationship between the Xs and Ys is in the **model.fit** call. This is where it will go through the loop we spoke about above, making a guess, measuring how good or bad it is (aka the loss), using the opimizer to make another guess etc. It will do it for the number of epochs you specify. When you run this code, you'll see the loss on the right hand side."
]
},
{
"metadata": {
"id": "lpRrl7WK10Pq",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 17473
},
"outputId": "8b114b02-e08c-4b53-c14c-d649a2287937"
},
"cell_type": "code",
"source": [
"model.fit(xs, ys, epochs=500)"
],
"execution_count": 5,
"outputs": [
{
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.cast instead.\n",
"Epoch 1/500\n",
"6/6 [==============================] - 1s 84ms/sample - loss: 17.4085\n",
"Epoch 2/500\n",
"6/6 [==============================] - 0s 820us/sample - loss: 13.9493\n",
"Epoch 3/500\n",
"6/6 [==============================] - 0s 604us/sample - loss: 11.2225\n",
"Epoch 4/500\n",
"6/6 [==============================] - 0s 537us/sample - loss: 9.0721\n",
"Epoch 5/500\n",
"6/6 [==============================] - 0s 647us/sample - loss: 7.3753\n",
"Epoch 6/500\n",
"6/6 [==============================] - 0s 275us/sample - loss: 6.0355\n",
"Epoch 7/500\n",
"6/6 [==============================] - 0s 267us/sample - loss: 4.9766\n",
"Epoch 8/500\n",
"6/6 [==============================] - 0s 588us/sample - loss: 4.1388\n",
"Epoch 9/500\n",
"6/6 [==============================] - 0s 631us/sample - loss: 3.4751\n",
"Epoch 10/500\n",
"6/6 [==============================] - 0s 303us/sample - loss: 2.9484\n",
"Epoch 11/500\n",
"6/6 [==============================] - 0s 788us/sample - loss: 2.5296\n",
"Epoch 12/500\n",
"6/6 [==============================] - 0s 607us/sample - loss: 2.1958\n",
"Epoch 13/500\n",
"6/6 [==============================] - 0s 380us/sample - loss: 1.9290\n",
"Epoch 14/500\n",
"6/6 [==============================] - 0s 277us/sample - loss: 1.7149\n",
"Epoch 15/500\n",
"6/6 [==============================] - 0s 278us/sample - loss: 1.5425\n",
"Epoch 16/500\n",
"6/6 [==============================] - 0s 260us/sample - loss: 1.4028\n",
"Epoch 17/500\n",
"6/6 [==============================] - 0s 249us/sample - loss: 1.2891\n",
"Epoch 18/500\n",
"6/6 [==============================] - 0s 237us/sample - loss: 1.1957\n",
"Epoch 19/500\n",
"6/6 [==============================] - 0s 253us/sample - loss: 1.1186\n",
"Epoch 20/500\n",
"6/6 [==============================] - 0s 258us/sample - loss: 1.0543\n",
"Epoch 21/500\n",
"6/6 [==============================] - 0s 226us/sample - loss: 1.0001\n",
"Epoch 22/500\n",
"6/6 [==============================] - 0s 313us/sample - loss: 0.9539\n",
"Epoch 23/500\n",
"6/6 [==============================] - 0s 259us/sample - loss: 0.9142\n",
"Epoch 24/500\n",
"6/6 [==============================] - 0s 255us/sample - loss: 0.8795\n",
"Epoch 25/500\n",
"6/6 [==============================] - 0s 214us/sample - loss: 0.8490\n",
"Epoch 26/500\n",
"6/6 [==============================] - 0s 201us/sample - loss: 0.8218\n",
"Epoch 27/500\n",
"6/6 [==============================] - 0s 218us/sample - loss: 0.7972\n",
"Epoch 28/500\n",
"6/6 [==============================] - 0s 212us/sample - loss: 0.7747\n",
"Epoch 29/500\n",
"6/6 [==============================] - 0s 214us/sample - loss: 0.7540\n",
"Epoch 30/500\n",
"6/6 [==============================] - 0s 216us/sample - loss: 0.7348\n",
"Epoch 31/500\n",
"6/6 [==============================] - 0s 207us/sample - loss: 0.7167\n",
"Epoch 32/500\n",
"6/6 [==============================] - 0s 244us/sample - loss: 0.6997\n",
"Epoch 33/500\n",
"6/6 [==============================] - 0s 227us/sample - loss: 0.6835\n",
"Epoch 34/500\n",
"6/6 [==============================] - 0s 249us/sample - loss: 0.6680\n",
"Epoch 35/500\n",
"6/6 [==============================] - 0s 224us/sample - loss: 0.6531\n",
"Epoch 36/500\n",
"6/6 [==============================] - 0s 207us/sample - loss: 0.6388\n",
"Epoch 37/500\n",
"6/6 [==============================] - 0s 251us/sample - loss: 0.6250\n",
"Epoch 38/500\n",
"6/6 [==============================] - 0s 223us/sample - loss: 0.6116\n",
"Epoch 39/500\n",
"6/6 [==============================] - 0s 213us/sample - loss: 0.5986\n",
"Epoch 40/500\n",
"6/6 [==============================] - 0s 221us/sample - loss: 0.5860\n",
"Epoch 41/500\n",
"6/6 [==============================] - 0s 202us/sample - loss: 0.5737\n",
"Epoch 42/500\n",
"6/6 [==============================] - 0s 216us/sample - loss: 0.5617\n",
"Epoch 43/500\n",
"6/6 [==============================] - 0s 203us/sample - loss: 0.5500\n",
"Epoch 44/500\n",
"6/6 [==============================] - 0s 212us/sample - loss: 0.5386\n",
"Epoch 45/500\n",
"6/6 [==============================] - 0s 203us/sample - loss: 0.5274\n",
"Epoch 46/500\n",
"6/6 [==============================] - 0s 213us/sample - loss: 0.5165\n",
"Epoch 47/500\n",
"6/6 [==============================] - 0s 218us/sample - loss: 0.5058\n",
"Epoch 48/500\n",
"6/6 [==============================] - 0s 238us/sample - loss: 0.4954\n",
"Epoch 49/500\n",
"6/6 [==============================] - 0s 216us/sample - loss: 0.4851\n",
"Epoch 50/500\n",
"6/6 [==============================] - 0s 219us/sample - loss: 0.4752\n",
"Epoch 51/500\n",
"6/6 [==============================] - 0s 202us/sample - loss: 0.4654\n",
"Epoch 52/500\n",
"6/6 [==============================] - 0s 201us/sample - loss: 0.4558\n",
"Epoch 53/500\n",
"6/6 [==============================] - 0s 249us/sample - loss: 0.4464\n",
"Epoch 54/500\n",
"6/6 [==============================] - 0s 207us/sample - loss: 0.4372\n",
"Epoch 55/500\n",
"6/6 [==============================] - 0s 213us/sample - loss: 0.4282\n",
"Epoch 56/500\n",
"6/6 [==============================] - 0s 212us/sample - loss: 0.4194\n",
"Epoch 57/500\n",
"6/6 [==============================] - 0s 216us/sample - loss: 0.4108\n",
"Epoch 58/500\n",
"6/6 [==============================] - 0s 193us/sample - loss: 0.4024\n",
"Epoch 59/500\n",
"6/6 [==============================] - 0s 209us/sample - loss: 0.3941\n",
"Epoch 60/500\n",
"6/6 [==============================] - 0s 202us/sample - loss: 0.3860\n",
"Epoch 61/500\n",
"6/6 [==============================] - 0s 230us/sample - loss: 0.3781\n",
"Epoch 62/500\n",
"6/6 [==============================] - 0s 356us/sample - loss: 0.3703\n",
"Epoch 63/500\n",
"6/6 [==============================] - 0s 214us/sample - loss: 0.3627\n",
"Epoch 64/500\n",
"6/6 [==============================] - 0s 217us/sample - loss: 0.3552\n",
"Epoch 65/500\n",
"6/6 [==============================] - 0s 438us/sample - loss: 0.3479\n",
"Epoch 66/500\n",
"6/6 [==============================] - 0s 187us/sample - loss: 0.3408\n",
"Epoch 67/500\n",
"6/6 [==============================] - 0s 217us/sample - loss: 0.3338\n",
"Epoch 68/500\n",
"6/6 [==============================] - 0s 452us/sample - loss: 0.3269\n",
"Epoch 69/500\n",
"6/6 [==============================] - 0s 264us/sample - loss: 0.3202\n",
"Epoch 70/500\n",
"6/6 [==============================] - 0s 203us/sample - loss: 0.3136\n",
"Epoch 71/500\n",
"6/6 [==============================] - 0s 239us/sample - loss: 0.3072\n",
"Epoch 72/500\n",
"6/6 [==============================] - 0s 215us/sample - loss: 0.3009\n",
"Epoch 73/500\n",
"6/6 [==============================] - 0s 211us/sample - loss: 0.2947\n",
"Epoch 74/500\n",
"6/6 [==============================] - 0s 217us/sample - loss: 0.2887\n",
"Epoch 75/500\n",
"6/6 [==============================] - 0s 238us/sample - loss: 0.2827\n",
"Epoch 76/500\n",
"6/6 [==============================] - 0s 213us/sample - loss: 0.2769\n",
"Epoch 77/500\n",
"6/6 [==============================] - 0s 291us/sample - loss: 0.2712\n",
"Epoch 78/500\n",
"6/6 [==============================] - 0s 209us/sample - loss: 0.2657\n",
"Epoch 79/500\n",
"6/6 [==============================] - 0s 203us/sample - loss: 0.2602\n",
"Epoch 80/500\n",
"6/6 [==============================] - 0s 208us/sample - loss: 0.2549\n",
"Epoch 81/500\n",
"6/6 [==============================] - 0s 215us/sample - loss: 0.2496\n",
"Epoch 82/500\n",
"6/6 [==============================] - 0s 217us/sample - loss: 0.2445\n",
"Epoch 83/500\n",
"6/6 [==============================] - 0s 211us/sample - loss: 0.2395\n",
"Epoch 84/500\n",
"6/6 [==============================] - 0s 221us/sample - loss: 0.2346\n",
"Epoch 85/500\n",
"6/6 [==============================] - 0s 226us/sample - loss: 0.2297\n",
"Epoch 86/500\n",
"6/6 [==============================] - 0s 210us/sample - loss: 0.2250\n",
"Epoch 87/500\n",
"6/6 [==============================] - 0s 254us/sample - loss: 0.2204\n",
"Epoch 88/500\n",
"6/6 [==============================] - 0s 267us/sample - loss: 0.2159\n",
"Epoch 89/500\n",
"6/6 [==============================] - 0s 258us/sample - loss: 0.2114\n",
"Epoch 90/500\n",
"6/6 [==============================] - 0s 262us/sample - loss: 0.2071\n",
"Epoch 91/500\n",
"6/6 [==============================] - 0s 263us/sample - loss: 0.2028\n",
"Epoch 92/500\n",
"6/6 [==============================] - 0s 234us/sample - loss: 0.1987\n",
"Epoch 93/500\n",
"6/6 [==============================] - 0s 237us/sample - loss: 0.1946\n",
"Epoch 94/500\n",
"6/6 [==============================] - 0s 249us/sample - loss: 0.1906\n",
"Epoch 95/500\n",
"6/6 [==============================] - 0s 260us/sample - loss: 0.1867\n",
"Epoch 96/500\n",
"6/6 [==============================] - 0s 257us/sample - loss: 0.1828\n",
"Epoch 97/500\n",
"6/6 [==============================] - 0s 288us/sample - loss: 0.1791\n",
"Epoch 98/500\n",
"6/6 [==============================] - 0s 261us/sample - loss: 0.1754\n",
"Epoch 99/500\n",
"6/6 [==============================] - 0s 250us/sample - loss: 0.1718\n",
"Epoch 100/500\n",
"6/6 [==============================] - 0s 330us/sample - loss: 0.1683\n",
"Epoch 101/500\n",
"6/6 [==============================] - 0s 252us/sample - loss: 0.1648\n",
"Epoch 102/500\n",
"6/6 [==============================] - 0s 239us/sample - loss: 0.1614\n",
"Epoch 103/500\n",
"6/6 [==============================] - 0s 481us/sample - loss: 0.1581\n",
"Epoch 104/500\n",
"6/6 [==============================] - 0s 210us/sample - loss: 0.1549\n",
"Epoch 105/500\n",
"6/6 [==============================] - 0s 255us/sample - loss: 0.1517\n",
"Epoch 106/500\n",
"6/6 [==============================] - 0s 235us/sample - loss: 0.1486\n",
"Epoch 107/500\n",
"6/6 [==============================] - 0s 237us/sample - loss: 0.1455\n",
"Epoch 108/500\n",
"6/6 [==============================] - 0s 247us/sample - loss: 0.1425\n",
"Epoch 109/500\n",
"6/6 [==============================] - 0s 576us/sample - loss: 0.1396\n",
"Epoch 110/500\n",
"6/6 [==============================] - 0s 215us/sample - loss: 0.1367\n",
"Epoch 111/500\n",
"6/6 [==============================] - 0s 209us/sample - loss: 0.1339\n",
"Epoch 112/500\n",
"6/6 [==============================] - 0s 207us/sample - loss: 0.1312\n",
"Epoch 113/500\n",
"6/6 [==============================] - 0s 222us/sample - loss: 0.1285\n",
"Epoch 114/500\n",
"6/6 [==============================] - 0s 219us/sample - loss: 0.1258\n",
"Epoch 115/500\n",
"6/6 [==============================] - 0s 222us/sample - loss: 0.1233\n",
"Epoch 116/500\n",
"6/6 [==============================] - 0s 261us/sample - loss: 0.1207\n",
"Epoch 117/500\n",
"6/6 [==============================] - 0s 273us/sample - loss: 0.1183\n",
"Epoch 118/500\n",
"6/6 [==============================] - 0s 833us/sample - loss: 0.1158\n",
"Epoch 119/500\n",
"6/6 [==============================] - 0s 353us/sample - loss: 0.1134\n",
"Epoch 120/500\n",
"6/6 [==============================] - 0s 266us/sample - loss: 0.1111\n",
"Epoch 121/500\n",
"6/6 [==============================] - 0s 334us/sample - loss: 0.1088\n",
"Epoch 122/500\n",
"6/6 [==============================] - 0s 285us/sample - loss: 0.1066\n",
"Epoch 123/500\n",
"6/6 [==============================] - 0s 234us/sample - loss: 0.1044\n",
"Epoch 124/500\n",
"6/6 [==============================] - 0s 235us/sample - loss: 0.1023\n",
"Epoch 125/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 0.1002\n",
"Epoch 126/500\n",
"6/6 [==============================] - 0s 220us/sample - loss: 0.0981\n",
"Epoch 127/500\n",
"6/6 [==============================] - 0s 240us/sample - loss: 0.0961\n",
"Epoch 128/500\n",
"6/6 [==============================] - 0s 172us/sample - loss: 0.0941\n",
"Epoch 129/500\n",
"6/6 [==============================] - 0s 367us/sample - loss: 0.0922\n",
"Epoch 130/500\n",
"6/6 [==============================] - 0s 266us/sample - loss: 0.0903\n",
"Epoch 131/500\n",
"6/6 [==============================] - 0s 176us/sample - loss: 0.0884\n",
"Epoch 132/500\n",
"6/6 [==============================] - 0s 370us/sample - loss: 0.0866\n",
"Epoch 133/500\n",
"6/6 [==============================] - 0s 249us/sample - loss: 0.0848\n",
"Epoch 134/500\n",
"6/6 [==============================] - 0s 242us/sample - loss: 0.0831\n",
"Epoch 135/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 0.0814\n",
"Epoch 136/500\n",
"6/6 [==============================] - 0s 188us/sample - loss: 0.0797\n",
"Epoch 137/500\n",
"6/6 [==============================] - 0s 482us/sample - loss: 0.0781\n",
"Epoch 138/500\n",
"6/6 [==============================] - 0s 170us/sample - loss: 0.0765\n",
"Epoch 139/500\n",
"6/6 [==============================] - 0s 217us/sample - loss: 0.0749\n",
"Epoch 140/500\n",
"6/6 [==============================] - 0s 395us/sample - loss: 0.0734\n",
"Epoch 141/500\n",
"6/6 [==============================] - 0s 243us/sample - loss: 0.0719\n",
"Epoch 142/500\n",
"6/6 [==============================] - 0s 170us/sample - loss: 0.0704\n",
"Epoch 143/500\n",
"6/6 [==============================] - 0s 248us/sample - loss: 0.0689\n",
"Epoch 144/500\n",
"6/6 [==============================] - 0s 232us/sample - loss: 0.0675\n",
"Epoch 145/500\n",
"6/6 [==============================] - 0s 176us/sample - loss: 0.0661\n",
"Epoch 146/500\n",
"6/6 [==============================] - 0s 238us/sample - loss: 0.0648\n",
"Epoch 147/500\n",
"6/6 [==============================] - 0s 243us/sample - loss: 0.0634\n",
"Epoch 148/500\n",
"6/6 [==============================] - 0s 243us/sample - loss: 0.0621\n",
"Epoch 149/500\n",
"6/6 [==============================] - 0s 398us/sample - loss: 0.0609\n",
"Epoch 150/500\n",
"6/6 [==============================] - 0s 172us/sample - loss: 0.0596\n",
"Epoch 151/500\n",
"6/6 [==============================] - 0s 170us/sample - loss: 0.0584\n",
"Epoch 152/500\n",
"6/6 [==============================] - 0s 239us/sample - loss: 0.0572\n",
"Epoch 153/500\n",
"6/6 [==============================] - 0s 172us/sample - loss: 0.0560\n",
"Epoch 154/500\n",
"6/6 [==============================] - 0s 237us/sample - loss: 0.0549\n",
"Epoch 155/500\n",
"6/6 [==============================] - 0s 184us/sample - loss: 0.0537\n",
"Epoch 156/500\n",
"6/6 [==============================] - 0s 180us/sample - loss: 0.0526\n",
"Epoch 157/500\n",
"6/6 [==============================] - 0s 427us/sample - loss: 0.0516\n",
"Epoch 158/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 0.0505\n",
"Epoch 159/500\n",
"6/6 [==============================] - 0s 253us/sample - loss: 0.0495\n",
"Epoch 160/500\n",
"6/6 [==============================] - 0s 240us/sample - loss: 0.0484\n",
"Epoch 161/500\n",
"6/6 [==============================] - 0s 239us/sample - loss: 0.0474\n",
"Epoch 162/500\n",
"6/6 [==============================] - 0s 234us/sample - loss: 0.0465\n",
"Epoch 163/500\n",
"6/6 [==============================] - 0s 202us/sample - loss: 0.0455\n",
"Epoch 164/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0446\n",
"Epoch 165/500\n",
"6/6 [==============================] - 0s 235us/sample - loss: 0.0437\n",
"Epoch 166/500\n",
"6/6 [==============================] - 0s 496us/sample - loss: 0.0428\n",
"Epoch 167/500\n",
"6/6 [==============================] - 0s 172us/sample - loss: 0.0419\n",
"Epoch 168/500\n",
"6/6 [==============================] - 0s 254us/sample - loss: 0.0410\n",
"Epoch 169/500\n",
"6/6 [==============================] - 0s 177us/sample - loss: 0.0402\n",
"Epoch 170/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0394\n",
"Epoch 171/500\n",
"6/6 [==============================] - 0s 175us/sample - loss: 0.0386\n",
"Epoch 172/500\n",
"6/6 [==============================] - 0s 167us/sample - loss: 0.0378\n",
"Epoch 173/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 0.0370\n",
"Epoch 174/500\n",
"6/6 [==============================] - 0s 417us/sample - loss: 0.0362\n",
"Epoch 175/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0355\n",
"Epoch 176/500\n",
"6/6 [==============================] - 0s 204us/sample - loss: 0.0348\n",
"Epoch 177/500\n",
"6/6 [==============================] - 0s 282us/sample - loss: 0.0340\n",
"Epoch 178/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0333\n",
"Epoch 179/500\n",
"6/6 [==============================] - 0s 247us/sample - loss: 0.0327\n",
"Epoch 180/500\n",
"6/6 [==============================] - 0s 178us/sample - loss: 0.0320\n",
"Epoch 181/500\n",
"6/6 [==============================] - 0s 170us/sample - loss: 0.0313\n",
"Epoch 182/500\n",
"6/6 [==============================] - 0s 415us/sample - loss: 0.0307\n",
"Epoch 183/500\n",
"6/6 [==============================] - 0s 179us/sample - loss: 0.0301\n",
"Epoch 184/500\n",
"6/6 [==============================] - 0s 176us/sample - loss: 0.0294\n",
"Epoch 185/500\n",
"6/6 [==============================] - 0s 320us/sample - loss: 0.0288\n",
"Epoch 186/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 0.0282\n",
"Epoch 187/500\n",
"6/6 [==============================] - 0s 178us/sample - loss: 0.0277\n",
"Epoch 188/500\n",
"6/6 [==============================] - 0s 272us/sample - loss: 0.0271\n",
"Epoch 189/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 0.0265\n",
"Epoch 190/500\n",
"6/6 [==============================] - 0s 170us/sample - loss: 0.0260\n",
"Epoch 191/500\n",
"6/6 [==============================] - 0s 187us/sample - loss: 0.0255\n",
"Epoch 192/500\n",
"6/6 [==============================] - 0s 240us/sample - loss: 0.0249\n",
"Epoch 193/500\n",
"6/6 [==============================] - 0s 230us/sample - loss: 0.0244\n",
"Epoch 194/500\n",
"6/6 [==============================] - 0s 230us/sample - loss: 0.0239\n",
"Epoch 195/500\n",
"6/6 [==============================] - 0s 511us/sample - loss: 0.0234\n",
"Epoch 196/500\n",
"6/6 [==============================] - 0s 228us/sample - loss: 0.0229\n",
"Epoch 197/500\n",
"6/6 [==============================] - 0s 280us/sample - loss: 0.0225\n",
"Epoch 198/500\n",
"6/6 [==============================] - 0s 234us/sample - loss: 0.0220\n",
"Epoch 199/500\n",
"6/6 [==============================] - 0s 238us/sample - loss: 0.0216\n",
"Epoch 200/500\n",
"6/6 [==============================] - 0s 278us/sample - loss: 0.0211\n",
"Epoch 201/500\n",
"6/6 [==============================] - 0s 277us/sample - loss: 0.0207\n",
"Epoch 202/500\n",
"6/6 [==============================] - 0s 232us/sample - loss: 0.0203\n",
"Epoch 203/500\n",
"6/6 [==============================] - 0s 243us/sample - loss: 0.0198\n",
"Epoch 204/500\n",
"6/6 [==============================] - 0s 329us/sample - loss: 0.0194\n",
"Epoch 205/500\n",
"6/6 [==============================] - 0s 174us/sample - loss: 0.0190\n",
"Epoch 206/500\n",
"6/6 [==============================] - 0s 224us/sample - loss: 0.0186\n",
"Epoch 207/500\n",
"6/6 [==============================] - 0s 278us/sample - loss: 0.0183\n",
"Epoch 208/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 0.0179\n",
"Epoch 209/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 0.0175\n",
"Epoch 210/500\n",
"6/6 [==============================] - 0s 243us/sample - loss: 0.0172\n",
"Epoch 211/500\n",
"6/6 [==============================] - 0s 196us/sample - loss: 0.0168\n",
"Epoch 212/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0165\n",
"Epoch 213/500\n",
"6/6 [==============================] - 0s 175us/sample - loss: 0.0161\n",
"Epoch 214/500\n",
"6/6 [==============================] - 0s 228us/sample - loss: 0.0158\n",
"Epoch 215/500\n",
"6/6 [==============================] - 0s 328us/sample - loss: 0.0155\n",
"Epoch 216/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 0.0152\n",
"Epoch 217/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 0.0148\n",
"Epoch 218/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 0.0145\n",
"Epoch 219/500\n",
"6/6 [==============================] - 0s 175us/sample - loss: 0.0142\n",
"Epoch 220/500\n",
"6/6 [==============================] - 0s 172us/sample - loss: 0.0139\n",
"Epoch 221/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 0.0137\n",
"Epoch 222/500\n",
"6/6 [==============================] - 0s 369us/sample - loss: 0.0134\n",
"Epoch 223/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 0.0131\n",
"Epoch 224/500\n",
"6/6 [==============================] - 0s 172us/sample - loss: 0.0128\n",
"Epoch 225/500\n",
"6/6 [==============================] - 0s 416us/sample - loss: 0.0126\n",
"Epoch 226/500\n",
"6/6 [==============================] - 0s 316us/sample - loss: 0.0123\n",
"Epoch 227/500\n",
"6/6 [==============================] - 0s 433us/sample - loss: 0.0121\n",
"Epoch 228/500\n",
"6/6 [==============================] - 0s 174us/sample - loss: 0.0118\n",
"Epoch 229/500\n",
"6/6 [==============================] - 0s 170us/sample - loss: 0.0116\n",
"Epoch 230/500\n",
"6/6 [==============================] - 0s 172us/sample - loss: 0.0113\n",
"Epoch 231/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 0.0111\n",
"Epoch 232/500\n",
"6/6 [==============================] - 0s 234us/sample - loss: 0.0109\n",
"Epoch 233/500\n",
"6/6 [==============================] - 0s 234us/sample - loss: 0.0106\n",
"Epoch 234/500\n",
"6/6 [==============================] - 0s 250us/sample - loss: 0.0104\n",
"Epoch 235/500\n",
"6/6 [==============================] - 0s 170us/sample - loss: 0.0102\n",
"Epoch 236/500\n",
"6/6 [==============================] - 0s 316us/sample - loss: 0.0100\n",
"Epoch 237/500\n",
"6/6 [==============================] - 0s 174us/sample - loss: 0.0098\n",
"Epoch 238/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 0.0096\n",
"Epoch 239/500\n",
"6/6 [==============================] - 0s 359us/sample - loss: 0.0094\n",
"Epoch 240/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 0.0092\n",
"Epoch 241/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0090\n",
"Epoch 242/500\n",
"6/6 [==============================] - 0s 362us/sample - loss: 0.0088\n",
"Epoch 243/500\n",
"6/6 [==============================] - 0s 177us/sample - loss: 0.0087\n",
"Epoch 244/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0085\n",
"Epoch 245/500\n",
"6/6 [==============================] - 0s 225us/sample - loss: 0.0083\n",
"Epoch 246/500\n",
"6/6 [==============================] - 0s 371us/sample - loss: 0.0081\n",
"Epoch 247/500\n",
"6/6 [==============================] - 0s 392us/sample - loss: 0.0080\n",
"Epoch 248/500\n",
"6/6 [==============================] - 0s 224us/sample - loss: 0.0078\n",
"Epoch 249/500\n",
"6/6 [==============================] - 0s 223us/sample - loss: 0.0076\n",
"Epoch 250/500\n",
"6/6 [==============================] - 0s 217us/sample - loss: 0.0075\n",
"Epoch 251/500\n",
"6/6 [==============================] - 0s 228us/sample - loss: 0.0073\n",
"Epoch 252/500\n",
"6/6 [==============================] - 0s 231us/sample - loss: 0.0072\n",
"Epoch 253/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 0.0070\n",
"Epoch 254/500\n",
"6/6 [==============================] - 0s 311us/sample - loss: 0.0069\n",
"Epoch 255/500\n",
"6/6 [==============================] - 0s 224us/sample - loss: 0.0067\n",
"Epoch 256/500\n",
"6/6 [==============================] - 0s 223us/sample - loss: 0.0066\n",
"Epoch 257/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 0.0065\n",
"Epoch 258/500\n",
"6/6 [==============================] - 0s 230us/sample - loss: 0.0063\n",
"Epoch 259/500\n",
"6/6 [==============================] - 0s 172us/sample - loss: 0.0062\n",
"Epoch 260/500\n",
"6/6 [==============================] - 0s 164us/sample - loss: 0.0061\n",
"Epoch 261/500\n",
"6/6 [==============================] - 0s 315us/sample - loss: 0.0060\n",
"Epoch 262/500\n",
"6/6 [==============================] - 0s 223us/sample - loss: 0.0058\n",
"Epoch 263/500\n",
"6/6 [==============================] - 0s 227us/sample - loss: 0.0057\n",
"Epoch 264/500\n",
"6/6 [==============================] - 0s 296us/sample - loss: 0.0056\n",
"Epoch 265/500\n",
"6/6 [==============================] - 0s 390us/sample - loss: 0.0055\n",
"Epoch 266/500\n",
"6/6 [==============================] - 0s 265us/sample - loss: 0.0054\n",
"Epoch 267/500\n",
"6/6 [==============================] - 0s 265us/sample - loss: 0.0053\n",
"Epoch 268/500\n",
"6/6 [==============================] - 0s 455us/sample - loss: 0.0051\n",
"Epoch 269/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 0.0050\n",
"Epoch 270/500\n",
"6/6 [==============================] - 0s 405us/sample - loss: 0.0049\n",
"Epoch 271/500\n",
"6/6 [==============================] - 0s 221us/sample - loss: 0.0048\n",
"Epoch 272/500\n",
"6/6 [==============================] - 0s 227us/sample - loss: 0.0047\n",
"Epoch 273/500\n",
"6/6 [==============================] - 0s 239us/sample - loss: 0.0046\n",
"Epoch 274/500\n",
"6/6 [==============================] - 0s 303us/sample - loss: 0.0045\n",
"Epoch 275/500\n",
"6/6 [==============================] - 0s 259us/sample - loss: 0.0045\n",
"Epoch 276/500\n",
"6/6 [==============================] - 0s 209us/sample - loss: 0.0044\n",
"Epoch 277/500\n",
"6/6 [==============================] - 0s 215us/sample - loss: 0.0043\n",
"Epoch 278/500\n",
"6/6 [==============================] - 0s 270us/sample - loss: 0.0042\n",
"Epoch 279/500\n",
"6/6 [==============================] - 0s 268us/sample - loss: 0.0041\n",
"Epoch 280/500\n",
"6/6 [==============================] - 0s 426us/sample - loss: 0.0040\n",
"Epoch 281/500\n",
"6/6 [==============================] - 0s 211us/sample - loss: 0.0039\n",
"Epoch 282/500\n",
"6/6 [==============================] - 0s 576us/sample - loss: 0.0039\n",
"Epoch 283/500\n",
"6/6 [==============================] - 0s 212us/sample - loss: 0.0038\n",
"Epoch 284/500\n",
"6/6 [==============================] - 0s 259us/sample - loss: 0.0037\n",
"Epoch 285/500\n",
"6/6 [==============================] - 0s 290us/sample - loss: 0.0036\n",
"Epoch 286/500\n",
"6/6 [==============================] - 0s 261us/sample - loss: 0.0035\n",
"Epoch 287/500\n",
"6/6 [==============================] - 0s 428us/sample - loss: 0.0035\n",
"Epoch 288/500\n",
"6/6 [==============================] - 0s 189us/sample - loss: 0.0034\n",
"Epoch 289/500\n",
"6/6 [==============================] - 0s 222us/sample - loss: 0.0033\n",
"Epoch 290/500\n",
"6/6 [==============================] - 0s 161us/sample - loss: 0.0033\n",
"Epoch 291/500\n",
"6/6 [==============================] - 0s 236us/sample - loss: 0.0032\n",
"Epoch 292/500\n",
"6/6 [==============================] - 0s 181us/sample - loss: 0.0031\n",
"Epoch 293/500\n",
"6/6 [==============================] - 0s 186us/sample - loss: 0.0031\n",
"Epoch 294/500\n",
"6/6 [==============================] - 0s 182us/sample - loss: 0.0030\n",
"Epoch 295/500\n",
"6/6 [==============================] - 0s 205us/sample - loss: 0.0029\n",
"Epoch 296/500\n",
"6/6 [==============================] - 0s 174us/sample - loss: 0.0029\n",
"Epoch 297/500\n",
"6/6 [==============================] - 0s 199us/sample - loss: 0.0028\n",
"Epoch 298/500\n",
"6/6 [==============================] - 0s 198us/sample - loss: 0.0028\n",
"Epoch 299/500\n",
"6/6 [==============================] - 0s 202us/sample - loss: 0.0027\n",
"Epoch 300/500\n",
"6/6 [==============================] - 0s 175us/sample - loss: 0.0027\n",
"Epoch 301/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 0.0026\n",
"Epoch 302/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0025\n",
"Epoch 303/500\n",
"6/6 [==============================] - 0s 347us/sample - loss: 0.0025\n",
"Epoch 304/500\n",
"6/6 [==============================] - 0s 204us/sample - loss: 0.0024\n",
"Epoch 305/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 0.0024\n",
"Epoch 306/500\n",
"6/6 [==============================] - 0s 174us/sample - loss: 0.0023\n",
"Epoch 307/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 0.0023\n",
"Epoch 308/500\n",
"6/6 [==============================] - 0s 166us/sample - loss: 0.0022\n",
"Epoch 309/500\n",
"6/6 [==============================] - 0s 197us/sample - loss: 0.0022\n",
"Epoch 310/500\n",
"6/6 [==============================] - 0s 189us/sample - loss: 0.0022\n",
"Epoch 311/500\n",
"6/6 [==============================] - 0s 166us/sample - loss: 0.0021\n",
"Epoch 312/500\n",
"6/6 [==============================] - 0s 176us/sample - loss: 0.0021\n",
"Epoch 313/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0020\n",
"Epoch 314/500\n",
"6/6 [==============================] - 0s 201us/sample - loss: 0.0020\n",
"Epoch 315/500\n",
"6/6 [==============================] - 0s 209us/sample - loss: 0.0019\n",
"Epoch 316/500\n",
"6/6 [==============================] - 0s 201us/sample - loss: 0.0019\n",
"Epoch 317/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 0.0019\n",
"Epoch 318/500\n",
"6/6 [==============================] - 0s 183us/sample - loss: 0.0018\n",
"Epoch 319/500\n",
"6/6 [==============================] - 0s 189us/sample - loss: 0.0018\n",
"Epoch 320/500\n",
"6/6 [==============================] - 0s 230us/sample - loss: 0.0018\n",
"Epoch 321/500\n",
"6/6 [==============================] - 0s 177us/sample - loss: 0.0017\n",
"Epoch 322/500\n",
"6/6 [==============================] - 0s 412us/sample - loss: 0.0017\n",
"Epoch 323/500\n",
"6/6 [==============================] - 0s 178us/sample - loss: 0.0016\n",
"Epoch 324/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0016\n",
"Epoch 325/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0016\n",
"Epoch 326/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 0.0015\n",
"Epoch 327/500\n",
"6/6 [==============================] - 0s 177us/sample - loss: 0.0015\n",
"Epoch 328/500\n",
"6/6 [==============================] - 0s 198us/sample - loss: 0.0015\n",
"Epoch 329/500\n",
"6/6 [==============================] - 0s 435us/sample - loss: 0.0015\n",
"Epoch 330/500\n",
"6/6 [==============================] - 0s 166us/sample - loss: 0.0014\n",
"Epoch 331/500\n",
"6/6 [==============================] - 0s 202us/sample - loss: 0.0014\n",
"Epoch 332/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0014\n",
"Epoch 333/500\n",
"6/6 [==============================] - 0s 202us/sample - loss: 0.0013\n",
"Epoch 334/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 0.0013\n",
"Epoch 335/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 0.0013\n",
"Epoch 336/500\n",
"6/6 [==============================] - 0s 465us/sample - loss: 0.0013\n",
"Epoch 337/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 0.0012\n",
"Epoch 338/500\n",
"6/6 [==============================] - 0s 170us/sample - loss: 0.0012\n",
"Epoch 339/500\n",
"6/6 [==============================] - 0s 449us/sample - loss: 0.0012\n",
"Epoch 340/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0012\n",
"Epoch 341/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0011\n",
"Epoch 342/500\n",
"6/6 [==============================] - 0s 199us/sample - loss: 0.0011\n",
"Epoch 343/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 0.0011\n",
"Epoch 344/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 0.0011\n",
"Epoch 345/500\n",
"6/6 [==============================] - 0s 165us/sample - loss: 0.0010\n",
"Epoch 346/500\n",
"6/6 [==============================] - 0s 199us/sample - loss: 0.0010\n",
"Epoch 347/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 9.9927e-04\n",
"Epoch 348/500\n",
"6/6 [==============================] - 0s 167us/sample - loss: 9.7874e-04\n",
"Epoch 349/500\n",
"6/6 [==============================] - 0s 437us/sample - loss: 9.5864e-04\n",
"Epoch 350/500\n",
"6/6 [==============================] - 0s 166us/sample - loss: 9.3895e-04\n",
"Epoch 351/500\n",
"6/6 [==============================] - 0s 196us/sample - loss: 9.1966e-04\n",
"Epoch 352/500\n",
"6/6 [==============================] - 0s 182us/sample - loss: 9.0077e-04\n",
"Epoch 353/500\n",
"6/6 [==============================] - 0s 213us/sample - loss: 8.8227e-04\n",
"Epoch 354/500\n",
"6/6 [==============================] - 0s 202us/sample - loss: 8.6415e-04\n",
"Epoch 355/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 8.4639e-04\n",
"Epoch 356/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 8.2901e-04\n",
"Epoch 357/500\n",
"6/6 [==============================] - 0s 170us/sample - loss: 8.1198e-04\n",
"Epoch 358/500\n",
"6/6 [==============================] - 0s 196us/sample - loss: 7.9530e-04\n",
"Epoch 359/500\n",
"6/6 [==============================] - 0s 167us/sample - loss: 7.7897e-04\n",
"Epoch 360/500\n",
"6/6 [==============================] - 0s 167us/sample - loss: 7.6297e-04\n",
"Epoch 361/500\n",
"6/6 [==============================] - 0s 244us/sample - loss: 7.4730e-04\n",
"Epoch 362/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 7.3195e-04\n",
"Epoch 363/500\n",
"6/6 [==============================] - 0s 196us/sample - loss: 7.1691e-04\n",
"Epoch 364/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 7.0218e-04\n",
"Epoch 365/500\n",
"6/6 [==============================] - 0s 190us/sample - loss: 6.8776e-04\n",
"Epoch 366/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 6.7364e-04\n",
"Epoch 367/500\n",
"6/6 [==============================] - 0s 167us/sample - loss: 6.5980e-04\n",
"Epoch 368/500\n",
"6/6 [==============================] - 0s 197us/sample - loss: 6.4625e-04\n",
"Epoch 369/500\n",
"6/6 [==============================] - 0s 177us/sample - loss: 6.3297e-04\n",
"Epoch 370/500\n",
"6/6 [==============================] - 0s 178us/sample - loss: 6.1997e-04\n",
"Epoch 371/500\n",
"6/6 [==============================] - 0s 257us/sample - loss: 6.0723e-04\n",
"Epoch 372/500\n",
"6/6 [==============================] - 0s 197us/sample - loss: 5.9476e-04\n",
"Epoch 373/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 5.8254e-04\n",
"Epoch 374/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 5.7058e-04\n",
"Epoch 375/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 5.5886e-04\n",
"Epoch 376/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 5.4738e-04\n",
"Epoch 377/500\n",
"6/6 [==============================] - 0s 177us/sample - loss: 5.3614e-04\n",
"Epoch 378/500\n",
"6/6 [==============================] - 0s 198us/sample - loss: 5.2512e-04\n",
"Epoch 379/500\n",
"6/6 [==============================] - 0s 189us/sample - loss: 5.1433e-04\n",
"Epoch 380/500\n",
"6/6 [==============================] - 0s 236us/sample - loss: 5.0377e-04\n",
"Epoch 381/500\n",
"6/6 [==============================] - 0s 202us/sample - loss: 4.9342e-04\n",
"Epoch 382/500\n",
"6/6 [==============================] - 0s 166us/sample - loss: 4.8329e-04\n",
"Epoch 383/500\n",
"6/6 [==============================] - 0s 175us/sample - loss: 4.7336e-04\n",
"Epoch 384/500\n",
"6/6 [==============================] - 0s 216us/sample - loss: 4.6364e-04\n",
"Epoch 385/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 4.5411e-04\n",
"Epoch 386/500\n",
"6/6 [==============================] - 0s 191us/sample - loss: 4.4479e-04\n",
"Epoch 387/500\n",
"6/6 [==============================] - 0s 170us/sample - loss: 4.3565e-04\n",
"Epoch 388/500\n",
"6/6 [==============================] - 0s 177us/sample - loss: 4.2670e-04\n",
"Epoch 389/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 4.1794e-04\n",
"Epoch 390/500\n",
"6/6 [==============================] - 0s 168us/sample - loss: 4.0935e-04\n",
"Epoch 391/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 4.0095e-04\n",
"Epoch 392/500\n",
"6/6 [==============================] - 0s 173us/sample - loss: 3.9271e-04\n",
"Epoch 393/500\n",
"6/6 [==============================] - 0s 172us/sample - loss: 3.8464e-04\n",
"Epoch 394/500\n",
"6/6 [==============================] - 0s 169us/sample - loss: 3.7674e-04\n",
"Epoch 395/500\n",
"6/6 [==============================] - 0s 199us/sample - loss: 3.6901e-04\n",
"Epoch 396/500\n",
"6/6 [==============================] - 0s 172us/sample - loss: 3.6143e-04\n",
"Epoch 397/500\n",
"6/6 [==============================] - 0s 172us/sample - loss: 3.5400e-04\n",
"Epoch 398/500\n",
"6/6 [==============================] - 0s 171us/sample - loss: 3.4673e-04\n",
"Epoch 399/500\n",
"6/6 [==============================] - 0s 461us/sample - loss: 3.3961e-04\n",
"Epoch 400/500\n",
"6/6 [==============================] - 0s 167us/sample - loss: 3.3263e-04\n",
"Epoch 401/500\n",
"6/6 [==============================] - 0s 181us/sample - loss: 3.2580e-04\n",
"Epoch 402/500\n",
"6/6 [==============================] - 0s 180us/sample - loss: 3.1911e-04\n",
"Epoch 403/500\n",
"6/6 [==============================] - 0s 272us/sample - loss: 3.1256e-04\n",
"Epoch 404/500\n",
"6/6 [==============================] - 0s 239us/sample - loss: 3.0614e-04\n",
"Epoch 405/500\n",
"6/6 [==============================] - 0s 221us/sample - loss: 2.9984e-04\n",
"Epoch 406/500\n",
"6/6 [==============================] - 0s 229us/sample - loss: 2.9369e-04\n",
"Epoch 407/500\n",
"6/6 [==============================] - 0s 228us/sample - loss: 2.8765e-04\n",
"Epoch 408/500\n",
"6/6 [==============================] - 0s 238us/sample - loss: 2.8175e-04\n",
"Epoch 409/500\n",
"6/6 [==============================] - 0s 203us/sample - loss: 2.7596e-04\n",
"Epoch 410/500\n",
"6/6 [==============================] - 0s 236us/sample - loss: 2.7029e-04\n",
"Epoch 411/500\n",
"6/6 [==============================] - 0s 220us/sample - loss: 2.6474e-04\n",
"Epoch 412/500\n",
"6/6 [==============================] - 0s 251us/sample - loss: 2.5930e-04\n",
"Epoch 413/500\n",
"6/6 [==============================] - 0s 226us/sample - loss: 2.5397e-04\n",
"Epoch 414/500\n",
"6/6 [==============================] - 0s 235us/sample - loss: 2.4876e-04\n",
"Epoch 415/500\n",
"6/6 [==============================] - 0s 240us/sample - loss: 2.4365e-04\n",
"Epoch 416/500\n",
"6/6 [==============================] - 0s 243us/sample - loss: 2.3864e-04\n",
"Epoch 417/500\n",
"6/6 [==============================] - 0s 247us/sample - loss: 2.3374e-04\n",
"Epoch 418/500\n",
"6/6 [==============================] - 0s 211us/sample - loss: 2.2894e-04\n",
"Epoch 419/500\n",
"6/6 [==============================] - 0s 223us/sample - loss: 2.2424e-04\n",
"Epoch 420/500\n",
"6/6 [==============================] - 0s 229us/sample - loss: 2.1963e-04\n",
"Epoch 421/500\n",
"6/6 [==============================] - 0s 243us/sample - loss: 2.1512e-04\n",
"Epoch 422/500\n",
"6/6 [==============================] - 0s 236us/sample - loss: 2.1070e-04\n",
"Epoch 423/500\n",
"6/6 [==============================] - 0s 249us/sample - loss: 2.0637e-04\n",
"Epoch 424/500\n",
"6/6 [==============================] - 0s 212us/sample - loss: 2.0213e-04\n",
"Epoch 425/500\n",
"6/6 [==============================] - 0s 238us/sample - loss: 1.9798e-04\n",
"Epoch 426/500\n",
"6/6 [==============================] - 0s 242us/sample - loss: 1.9392e-04\n",
"Epoch 427/500\n",
"6/6 [==============================] - 0s 212us/sample - loss: 1.8993e-04\n",
"Epoch 428/500\n",
"6/6 [==============================] - 0s 217us/sample - loss: 1.8603e-04\n",
"Epoch 429/500\n",
"6/6 [==============================] - 0s 218us/sample - loss: 1.8221e-04\n",
"Epoch 430/500\n",
"6/6 [==============================] - 0s 224us/sample - loss: 1.7847e-04\n",
"Epoch 431/500\n",
"6/6 [==============================] - 0s 579us/sample - loss: 1.7480e-04\n",
"Epoch 432/500\n",
"6/6 [==============================] - 0s 254us/sample - loss: 1.7121e-04\n",
"Epoch 433/500\n",
"6/6 [==============================] - 0s 223us/sample - loss: 1.6770e-04\n",
"Epoch 434/500\n",
"6/6 [==============================] - 0s 207us/sample - loss: 1.6425e-04\n",
"Epoch 435/500\n",
"6/6 [==============================] - 0s 244us/sample - loss: 1.6088e-04\n",
"Epoch 436/500\n",
"6/6 [==============================] - 0s 226us/sample - loss: 1.5757e-04\n",
"Epoch 437/500\n",
"6/6 [==============================] - 0s 260us/sample - loss: 1.5434e-04\n",
"Epoch 438/500\n",
"6/6 [==============================] - 0s 240us/sample - loss: 1.5117e-04\n",
"Epoch 439/500\n",
"6/6 [==============================] - 0s 220us/sample - loss: 1.4806e-04\n",
"Epoch 440/500\n",
"6/6 [==============================] - 0s 211us/sample - loss: 1.4502e-04\n",
"Epoch 441/500\n",
"6/6 [==============================] - 0s 220us/sample - loss: 1.4204e-04\n",
"Epoch 442/500\n",
"6/6 [==============================] - 0s 215us/sample - loss: 1.3912e-04\n",
"Epoch 443/500\n",
"6/6 [==============================] - 0s 254us/sample - loss: 1.3627e-04\n",
"Epoch 444/500\n",
"6/6 [==============================] - 0s 207us/sample - loss: 1.3347e-04\n",
"Epoch 445/500\n",
"6/6 [==============================] - 0s 214us/sample - loss: 1.3073e-04\n",
"Epoch 446/500\n",
"6/6 [==============================] - 0s 240us/sample - loss: 1.2804e-04\n",
"Epoch 447/500\n",
"6/6 [==============================] - 0s 220us/sample - loss: 1.2541e-04\n",
"Epoch 448/500\n",
"6/6 [==============================] - 0s 219us/sample - loss: 1.2284e-04\n",
"Epoch 449/500\n",
"6/6 [==============================] - 0s 253us/sample - loss: 1.2031e-04\n",
"Epoch 450/500\n",
"6/6 [==============================] - 0s 209us/sample - loss: 1.1784e-04\n",
"Epoch 451/500\n",
"6/6 [==============================] - 0s 248us/sample - loss: 1.1542e-04\n",
"Epoch 452/500\n",
"6/6 [==============================] - 0s 244us/sample - loss: 1.1305e-04\n",
"Epoch 453/500\n",
"6/6 [==============================] - 0s 247us/sample - loss: 1.1073e-04\n",
"Epoch 454/500\n",
"6/6 [==============================] - 0s 220us/sample - loss: 1.0845e-04\n",
"Epoch 455/500\n",
"6/6 [==============================] - 0s 236us/sample - loss: 1.0623e-04\n",
"Epoch 456/500\n",
"6/6 [==============================] - 0s 250us/sample - loss: 1.0405e-04\n",
"Epoch 457/500\n",
"6/6 [==============================] - 0s 261us/sample - loss: 1.0191e-04\n",
"Epoch 458/500\n",
"6/6 [==============================] - 0s 209us/sample - loss: 9.9815e-05\n",
"Epoch 459/500\n",
"6/6 [==============================] - 0s 210us/sample - loss: 9.7765e-05\n",
"Epoch 460/500\n",
"6/6 [==============================] - 0s 267us/sample - loss: 9.5755e-05\n",
"Epoch 461/500\n",
"6/6 [==============================] - 0s 238us/sample - loss: 9.3788e-05\n",
"Epoch 462/500\n",
"6/6 [==============================] - 0s 214us/sample - loss: 9.1862e-05\n",
"Epoch 463/500\n",
"6/6 [==============================] - 0s 206us/sample - loss: 8.9975e-05\n",
"Epoch 464/500\n",
"6/6 [==============================] - 0s 222us/sample - loss: 8.8128e-05\n",
"Epoch 465/500\n",
"6/6 [==============================] - 0s 237us/sample - loss: 8.6318e-05\n",
"Epoch 466/500\n",
"6/6 [==============================] - 0s 207us/sample - loss: 8.4545e-05\n",
"Epoch 467/500\n",
"6/6 [==============================] - 0s 230us/sample - loss: 8.2806e-05\n",
"Epoch 468/500\n",
"6/6 [==============================] - 0s 234us/sample - loss: 8.1106e-05\n",
"Epoch 469/500\n",
"6/6 [==============================] - 0s 244us/sample - loss: 7.9441e-05\n",
"Epoch 470/500\n",
"6/6 [==============================] - 0s 210us/sample - loss: 7.7809e-05\n",
"Epoch 471/500\n",
"6/6 [==============================] - 0s 269us/sample - loss: 7.6210e-05\n",
"Epoch 472/500\n",
"6/6 [==============================] - 0s 249us/sample - loss: 7.4644e-05\n",
"Epoch 473/500\n",
"6/6 [==============================] - 0s 201us/sample - loss: 7.3112e-05\n",
"Epoch 474/500\n",
"6/6 [==============================] - 0s 218us/sample - loss: 7.1610e-05\n",
"Epoch 475/500\n",
"6/6 [==============================] - 0s 240us/sample - loss: 7.0139e-05\n",
"Epoch 476/500\n",
"6/6 [==============================] - 0s 208us/sample - loss: 6.8698e-05\n",
"Epoch 477/500\n",
"6/6 [==============================] - 0s 206us/sample - loss: 6.7287e-05\n",
"Epoch 478/500\n",
"6/6 [==============================] - 0s 246us/sample - loss: 6.5905e-05\n",
"Epoch 479/500\n",
"6/6 [==============================] - 0s 202us/sample - loss: 6.4551e-05\n",
"Epoch 480/500\n",
"6/6 [==============================] - 0s 243us/sample - loss: 6.3226e-05\n",
"Epoch 481/500\n",
"6/6 [==============================] - 0s 234us/sample - loss: 6.1928e-05\n",
"Epoch 482/500\n",
"6/6 [==============================] - 0s 251us/sample - loss: 6.0655e-05\n",
"Epoch 483/500\n",
"6/6 [==============================] - 0s 213us/sample - loss: 5.9410e-05\n",
"Epoch 484/500\n",
"6/6 [==============================] - 0s 242us/sample - loss: 5.8190e-05\n",
"Epoch 485/500\n",
"6/6 [==============================] - 0s 226us/sample - loss: 5.6994e-05\n",
"Epoch 486/500\n",
"6/6 [==============================] - 0s 238us/sample - loss: 5.5825e-05\n",
"Epoch 487/500\n",
"6/6 [==============================] - 0s 209us/sample - loss: 5.4678e-05\n",
"Epoch 488/500\n",
"6/6 [==============================] - 0s 245us/sample - loss: 5.3555e-05\n",
"Epoch 489/500\n",
"6/6 [==============================] - 0s 214us/sample - loss: 5.2455e-05\n",
"Epoch 490/500\n",
"6/6 [==============================] - 0s 244us/sample - loss: 5.1377e-05\n",
"Epoch 491/500\n",
"6/6 [==============================] - 0s 248us/sample - loss: 5.0321e-05\n",
"Epoch 492/500\n",
"6/6 [==============================] - 0s 243us/sample - loss: 4.9288e-05\n",
"Epoch 493/500\n",
"6/6 [==============================] - 0s 208us/sample - loss: 4.8275e-05\n",
"Epoch 494/500\n",
"6/6 [==============================] - 0s 245us/sample - loss: 4.7283e-05\n",
"Epoch 495/500\n",
"6/6 [==============================] - 0s 218us/sample - loss: 4.6313e-05\n",
"Epoch 496/500\n",
"6/6 [==============================] - 0s 244us/sample - loss: 4.5361e-05\n",
"Epoch 497/500\n",
"6/6 [==============================] - 0s 202us/sample - loss: 4.4430e-05\n",
"Epoch 498/500\n",
"6/6 [==============================] - 0s 210us/sample - loss: 4.3517e-05\n",
"Epoch 499/500\n",
"6/6 [==============================] - 0s 229us/sample - loss: 4.2624e-05\n",
"Epoch 500/500\n",
"6/6 [==============================] - 0s 211us/sample - loss: 4.1747e-05\n"
],
"name": "stdout"
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<tensorflow.python.keras.callbacks.History at 0x7fab75b03150>"
]
},
"metadata": {
"tags": []
},
"execution_count": 5
}
]
},
{
"metadata": {
"id": "kaFIr71H2OZ-",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"Ok, now you have a model that has been trained to learn the relationshop between X and Y. You can use the **model.predict** method to have it figure out the Y for a previously unknown X. So, for example, if X = 10, what do you think Y will be? Take a guess before you run this code:"
]
},
{
"metadata": {
"id": "OpDo3836L9Ef",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
""
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "oxNzL4lS2Gui",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "f5921bb0-3480-485b-8554-827ff102d362"
},
"cell_type": "code",
"source": [
"print(model.predict([10.0]))"
],
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"text": [
"[[18.98115]]\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "btF2CSFH2iEX",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"You might have thought 19, right? But it ended up being a little under. Why do you think that is? \n",
"\n",
"Remember that neural networks deal with probabilities, so given the data that we fed the NN with, it calculated that there is a very high probability that the relationship between X and Y is Y=2X-1, but with only 6 data points we can't know for sure. As a result, the result for 10 is very close to 19, but not necessarily 19. \n",
"\n",
"As you work with neural networks, you'll see this pattern recurring. You will almost always deal with probabilities, not certainties, and will do a little bit of coding to figure out what the result is based on the probabilities, particularly when it comes to classification.\n"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment