from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import numpy as np import matplotlib.pyplot as plt xx = np.arange (-5, 10, 0.5) yy = 3*xx**2 - 2*xx + 1 print (xx) print (yy) print("версия Tensorflow:", tf.__version__) print("используемое GPU:", tf.test.gpu_device_name()) xx = np.array(xx) yy = np.array(yy, dtype=float) for i, c in enumerate(xx): print("{} xx= {} yy " .format(c, yy[i])) l0 = tf.keras.layers.Dense(units=1, input_shape=[1]) model = tf.keras.Sequential([l0]) model.compile(loss='mean_squared_logarithmic_error', optimizer=tf.keras.optimizers.Adam(0.1)) history = model.fit(xx, yy, epochs=3000, verbose=False) print ("Завершили тренировку модели") plt.xlabel('Epoch') plt.ylabel('Loss') plt.plot(history.history['loss']) print(model.predict([-10.0])) print("Это значения переменных слоя: {}".format(l0.get_weights())) xx = np.linspace(-100, 100, 1000) yy = np.sin(xx) plt.plot(xx, yy) plt.show() from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import numpy as np import matplotlib.pyplot as plt xx = np.linspace(-100, 100, 1000) yy = np.sin(xx) plt.plot(xx, yy) plt.show() print("версия Tensorflow:", tf.__version__) print("используемое GPU:", tf.test.gpu_device_name()) for i, c in enumerate(xx): print("{} xx= {} yy " .format(c, yy[i])) l0 = tf.keras.layers.Dense(units=1, input_shape=[1]) model = tf.keras.Sequential([l0]) model.compile(loss='mean_squared_logarithmic_error', optimizer=tf.keras.optimizers.Adam(0.1)) history = model.fit(xx, yy, epochs=3000, verbose=False) print ("Завершили тренировку модели") plt.xlabel('Epoch') plt.ylabel('Loss') plt.plot(history.history['loss']) print(model.predict([-10.0])) print("Это значения переменных слоя: {}".format(l0.get_weights())) from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import numpy as np import matplotlib.pyplot as plt xx = np.linspace(-2, 2, 100) yy = np.exp(xx + 2) plt.plot(xx, yy) plt.show() print("версия Tensorflow:", tf.__version__) print("используемое GPU:", tf.test.gpu_device_name()) xx = np.array(xx) yy = np.array(yy, dtype=float) for i, c in enumerate(xx): print("{} xx= {} yy " .format(c, yy[i])) l0 = tf.keras.layers.Dense(units=1, input_shape=[1]) model = tf.keras.Sequential([l0]) model.compile(loss='mean_squared_logarithmic_error', optimizer=tf.keras.optimizers.Adam(0.1)) history = model.fit(xx, yy, epochs=3000, verbose=False) print ("Завершили тренировку модели") plt.xlabel('Epoch') plt.ylabel('Loss') plt.plot(history.history['loss']) print(model.predict([-10.0])) print("Это значения переменных слоя: {}".format(l0.get_weights()))