After spending days failing to use neural network for Q learning, I decided to go back to the basics and do a simple function approximation to see if everything was working
With these changes:
relu
kernel_initializer
(i.e. leave the default 'glorot_uniform'
)i.e.
regressor = Sequential()
regressor.add(Dense(units=20, activation='relu', input_dim=1))
regressor.add(Dense(units=20, activation='relu'))
regressor.add(Dense(units=20, activation='relu'))
regressor.add(Dense(units=1))
regressor.compile(loss='mean_squared_error', optimizer='adam')
regressor.fit(X, Y, epochs=100, verbose=1, batch_size=32)
and the rest of your code unchanged, here is the result:
Tinker, again and again...