import tensorflow as tf # Erstellen der Trainingsdaten inputMuster = [1, 2, 4, 312] outputMuster= [-1, 0, 2, 310] # Aufbau des neuronalen Netzwerkes model = tf.keras.Sequential() model.add(tf.keras.layers.Dense(1, input_shape=[1])) model.compile(optimizer='sgd', loss='mean_squared_error') # trainieren des neuronalen Netzwerkes model.fit(inputMuster, outputMuster, epochs=20) # Testen des neuronalen Netzwerkes mit Testdaten testMuster = [22] print(model.predict(testMuster))
Standard input is empty
Epoch 1/20 4/4 [==============================] - 0s 28ms/sample - loss: 43.5068 Epoch 2/20 4/4 [==============================] - 0s 224us/sample - loss: 9571612.0000 Epoch 3/20 4/4 [==============================] - 0s 200us/sample - loss: 2259196051456.0000 Epoch 4/20 4/4 [==============================] - 0s 245us/sample - loss: 533240255885606912.0000 Epoch 5/20 4/4 [==============================] - 0s 192us/sample - loss: 125861216080596287094784.0000 Epoch 6/20 4/4 [==============================] - 0s 225us/sample - loss: 29707153755431736148557299712.0000 Epoch 7/20 4/4 [==============================] - 0s 197us/sample - loss: 7011807510936047417394205223288832.0000 Epoch 8/20 4/4 [==============================] - 0s 180us/sample - loss: inf Epoch 9/20 4/4 [==============================] - 0s 181us/sample - loss: inf Epoch 10/20 4/4 [==============================] - 0s 182us/sample - loss: inf Epoch 11/20 4/4 [==============================] - 0s 185us/sample - loss: inf Epoch 12/20 4/4 [==============================] - 0s 183us/sample - loss: inf Epoch 13/20 4/4 [==============================] - 0s 176us/sample - loss: inf Epoch 14/20 4/4 [==============================] - 0s 178us/sample - loss: inf Epoch 15/20 4/4 [==============================] - 0s 179us/sample - loss: inf Epoch 16/20 4/4 [==============================] - 0s 183us/sample - loss: inf Epoch 17/20 4/4 [==============================] - 0s 182us/sample - loss: nan Epoch 18/20 4/4 [==============================] - 0s 178us/sample - loss: nan Epoch 19/20 4/4 [==============================] - 0s 177us/sample - loss: nan Epoch 20/20 4/4 [==============================] - 0s 188us/sample - loss: nan [[nan]]
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. Instructions for updating: Colocations handled automatically by placer. 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. Instructions for updating: Use tf.cast instead. 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. Instructions for updating: Use tf.cast instead.