Explain a little Python Keras and get me to predicting a sequence of numbers with Python Keras please :)

Job ID: 35371780

Budget: €8 – €30 EUR

I am new to Python Keras but I want to know how this code works. Can you explain what is the relation between x_input, y_input, input-var I made and the predicted output. Why the output is just one value and why does this program also work with y_input 5 values versus 1. So basically, how does this program work and how can I use a program like this for predicting a sequence of numbers?

import keras
import numpy as np
import logging
import tensorflow
from keras.layers import Dense
from tensorflow.python.keras.models import Sequential
# if __name__ == '__main__': print('PyCharm')

x_input = np.array([[1, 2, 3, 4, 5]])
y_input = np.array([[4]])

model = Sequential()
model.add(Dense(units=32, activation="tanh", input_dim=x_input.shape[1], kernel_initializer='random_normal'))
model.add(Dense(units=1, kernel_initializer='random_normal'))
model.compile(loss='mse', optimizer='sgd', metrics=['accuracy'])

# TRAINING
history = model.fit(x_input, y_input, epochs=10, batch_size=32, verbose=0)

# RUN
# print(model.test_on_batch(x_input))
# print()
inputs = np.array([[11, 12, 13, 14, 15]])
print(model.predict(inputs))
Related categories: Python Machine Learning (ML)