AI – Keras building model

Just tried to reproduce. My results differ from yours. Please check:

import tensorflow as tf
from tensorflow.keras.layers import Input, Dense
from tensorflow.keras import Model
inputA = Input(shape=(5, ))
x = Dense(20, activation='relu')(inputA)
x = Dense(20, activation='relu')(x)
x = Dense(1, activation='linear')(x)
model = Model(inputs=inputA, outputs=x)
model.compile(optimizer = 'adam', loss = 'mse')
input = tf.random.uniform([10000, 5], 0, 10, dtype=tf.int32)
labels = tf.random.uniform([10000, 1])
model.fit(input, labels, epochs=30, validation_split=0.2)

Results:

Epoch 1/30 250/250 [==============================] – 1s 3ms/step – loss: 0.1980 – val_loss: 0.1082

Epoch 2/30 250/250 [==============================] – 1s 2ms/step – loss: 0.0988 – val_loss: 0.0951

Epoch 3/30 250/250 [==============================] – 1s 2ms/step – loss: 0.0918 – val_loss: 0.0916

Epoch 4/30 250/250 [==============================] – 1s 2ms/step – loss: 0.0892 – val_loss: 0.0872

Epoch 5/30 250/250 [==============================] – 0s 2ms/step – loss: 0.0886 – val_loss: 0.0859

Epoch 6/30 250/250 [==============================] – 1s 2ms/step – loss: 0.0864 – val_loss: 0.0860

Epoch 7/30 250/250 [==============================] – 1s 3ms/step – loss: 0.0873 – val_loss: 0.0863

Epoch 8/30 250/250 [==============================] – 1s 2ms/step – loss: 0.0863 – val_loss: 0.0992

Epoch 9/30 250/250 [==============================] – 0s 2ms/step – loss: 0.0876 – val_loss: 0.0865

The model should work on real figures.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top