The simplest example?

Is there a simple example on Keras? Something on the level:

Input:
[0,0,1]

Output:
[0]


I have found many interesting examples, but they are difficult for me. I’d like to start with the easiest ones, not straight away with image recognition or text classification :rofl:

@000,

You can refer to this simplest example to train a neural network using data by feeding it with a set of X 's and a set of Y 's, it should be able to figure out the relationship between them.

model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')
xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)
ys = np.array([-2.0, 1.0, 4.0, 7.0, 10.0, 13.0], dtype=float)
model.fit(xs, ys, epochs=500)
print(model.predict([10.0]))

Thank you!

1 Like