Question: This is a general example of fitting data using an artificial neural network... data in (xs) should match data in (ys) and this represents a

This is a general example of fitting data using an artificial neural network... data in (xs) should match data in (ys) and this represents a training value for the neural network, when I start to test the first value in (xs) which is equal 443707.401 it should match the value in ys which is 443417.925 but the result is far.. how can you modify the code to fit the data? note:- you should test different value and it should reach the same value in ys

code is:

import tensorflow as tf import numpy as np from tensorflow import keras

# adding multiple layers to model to make the model complex for overfit the model # to give more accurate results for 443707.401 model=tf.keras.Sequential([ #keras.layers.Dense(50, activation="relu", name="layer1"), #keras.layers.Dense(50, activation="relu", name="layer2"), #keras.layers.Dense(50, activation="relu", name="layer3"), #keras.layers.Dense(50, activation="relu", name="layer4"), #keras.layers.Dense(25, activation="relu", name="layer5"), #keras.layers.Dense(10, activation="relu", name="layer6"), keras.layers.Dense(10, activation="relu", name="layer7"), keras.layers.Dense(5, activation="relu", name="layer8"), keras.layers.Dense(1, name="layer9"), ]) model.compile(optimizer='rmsprop',loss='mean_squared_error',metrics=['mae'])

a= float(input("enter the wanted value to convert : "))

xs=np.array([443707.401,455897.072, 396833.899,407426.699,435646.069, 419953.188,436349.443,633372.629, 572704.102,506379.29,596808.359, 622705.893,521749.843,500965.861, 558482.399,672648.564,739873.87, 459092.199,485007.612,579586.959, 509713.739,725009.687,727394.13, 658740.26,485686.823,461640.1,502495.219, 625584.252,680222.202,760907.585, 738381.47,712415.6], dtype=float)

ys=np.array([443417.925,455608.023, 397588.538,407135.987,435356.29, 419662.842,436059.613,633089.564, 572418.983,506091.937,596524.026, 622422.445,521463.004,500678.296, 558196.649,672366.797,739594.302, 458803.188,484719.43,579302.029, 509426.339,724729.561,727114.01, 658457.788,485398.691,461351.171, 502207.616,625300.699,679940.373, 760628.252,738101.41,712134.732],dtype=float)

# verbose till 2000 model.fit(xs,ys,epochs=200,verbose=1) result= (model.predict([a])) print(result)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!