My Neural Network Model is not Training Accurately. Please help me in this regard. My model is as follows
import tensorflow as tf
import numpy as np
import random
from tensorflow import keras
from tensorflow.keras import layers, optimizers, losses, Sequential
from keras.losses import MeanSquaredError
from tensorflow.keras.layers import Dense
import matplotlib.pyplot as plt
x = np.array(range(0,2000),dtype=float)
z = (x + x)**2
minz, maxz = min(z), max(z)
meanz = (minz+maxz)/2
for i in range(0,len(x)):
z[i] = (z[i] - meanz)/(maxz-minz)
x_train = tf.gather(x, indices= range(0,1000))
y_train = tf.gather(z, indices=range(0,1000))
model = keras.Sequential([
keras.layers.Dense(units=64, activation = ‘linear’, input_shape=[1]),
keras.layers.Dense(units=64, activation = ‘linear’),
keras.layers.Dense(units=64, activation = ‘linear’),
keras.layers.Dense(units=32, activation = ‘linear’),
keras.layers.Dense(units=1, activation = ‘linear’)
])
model.summary()
model.compile(keras.optimizers.Adam(learning_rate=0.001), loss = ‘mean_squared_error’, metrics=‘accuracy’)
model.fit(x_train,y_train,epochs=500)
zz = model.predict([10.0])
zp = print((zz*(maxz-minz) + meanz))