fork download
  1. import tensorflow as tf
  2.  
  3. # Erstellen der Trainingsdaten
  4. inputMuster = [1, 2, 4, 312]
  5. outputMuster= [-1, 0, 2, 310]
  6.  
  7. # Aufbau des neuronalen Netzwerkes
  8. model = tf.keras.Sequential()
  9. model.add(tf.keras.layers.Dense(1, input_shape=[1]))
  10. model.compile(optimizer='sgd', loss='mean_squared_error')
  11.  
  12. # trainieren des neuronalen Netzwerkes
  13. model.fit(inputMuster, outputMuster, epochs=20)
  14.  
  15. # Testen des neuronalen Netzwerkes mit Testdaten
  16. testMuster = [22]
  17. print(model.predict(testMuster))
Success #stdin #stdout #stderr 1.4s 213260KB
stdin
Standard input is empty
stdout
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]]
stderr
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.