I try to make my first prediction: 1,2,3 => 4,5,6

Hello !

I just finished “Advanced Leaning Algorithms” on coursera and would like to put my knowledge into practice.

To do this, I would like to make an algorithm that can predict that for example:

The sequence of [42, 43, 44] is [45, 46, 47].

I thought it would be very simple.

x = np.array([
    [1, 2, 3],
    [2, 3, 4],
    [3, 4, 5],
    [4, 5, 6],
    [5, 6, 7],
    [6, 7, 8],
    [7, 8, 9],
    [8, 9, 10],
    [9, 10, 11],
    [10001, 10002, 10003]
])

y = np.array([
    [4, 5, 6],
    [5, 6, 7],
    [6, 7, 8],
    [7, 8, 9],
    [8, 9, 10],
    [9, 10, 11],
    [10, 11, 12],
    [11, 12, 13],
    [12, 13, 14],
    [10004, 10005, 10006]
])

to_predict = [[42, 43, 44]]

I have tried several models that are very, very far from being right, while I thought that this simple model would allow to have zero loss.

model = tf.keras.models.Sequential([
  tf.keras.layers.Dense(2, activation='linear', input_shape=(3,)),
    tf.keras.layers.Dense(3, activation='linear')
])

model.compile(optimizer='adam', loss='mse')
model.fit(x, y, epochs=478)

result = model.predict(np.array(to_predict))

The example above gives me a more or less approximate result, but it’s fair if I put thousands of examples during the training.

It really amazes me, given the simplicity of the statement, to have a model that can’t get it right, and to have so many examples needed.

Do you have any advice for me?

Thank you very much !

@Emile,

Welcome to The Tensorflow Forum!

Neural networks only learn the function approximations in practice and we get close results. Please refer to this notebook for hello world example for tensorflow in practice.