Created
May 12, 2020 12:18
-
-
Save a46554/9083288745907be2d37f72bc5d4ef0a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
iport numpy as np | |
from tensorflow import keras | |
# Create an 1*1 layer neuron | |
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])]) | |
# Setting optimizer and loss function | |
model.compile(optimizer='sgd', loss='mean_squared_error') | |
# Training data | |
xs = np.array([1, 2, 3, 4], dtype=int) | |
ys = np.array([100, 150, 200, 250], dtype=int) | |
# Training mode for 500 iteration | |
model.fit(xs, ys, epochs=500) | |
# Predict the output | |
print(model.predict([7.0]))m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment