Hi Learners. I have developed a simple deep-learning model for a simple training example that comes from y=2*x -1. However, most of the time when I run the model, the loss values do not change and stick with a specific value. It happens 6 or 7 times from 10 times of running. This happens even I change the number of layers and neurons, learning epochs, and learning rate. Does anyone know the reason behind it?
My entire code is as follows:
import numpy as np
x = np.array([[-1.0, 0.0 , 1.0, 2.0, 3.0, 4.0, 5.0]])
y = np.array([[-3.0, -1.0, 1.0, 3.0, 5.0, 7.0, 9.0]])
x = np.reshape(x,(7,1))
y = np.reshape(y,(7,1))
from tensorflow import keras
from keras import Model
from keras.models import Sequential
from keras.layers import Input, Dense
input_1 = Input(shape=(1,))
dense_1 = Dense(4, activation=‘relu’)(input_1)
dense_2 = Dense(2, activation=‘relu’)(dense_1)
dense_3 = Dense(1, activation=‘relu’)(dense_2)
model_2 = Model(inputs= input_1, outputs = dense_3)
model_2.compile(loss = keras.losses.MeanSquaredError(),
optimizer = keras.optimizers.Adam(0.001))
model_2.fit(x,y, epochs=500)
print(model_2.predict([10]))