# Using Keras to Predict a Function Following a Normal Distribution

I am currently trying to predict a function that has a shape similar to that of a normal distribution. It is defined as:

(4 γΩ )/((γ+2nγ)^2+(4Δ^2+2Ω^2))


I have tried to use relu, sigmoid, and tanh activation functions.

I have also tried mae, mse and binary_crossentropy loss functions.

I have also tried adam, rmsprop and sgd optimizers, and have also played around with learning rates.

Nothing seems to work. When I perform a regression analysis, I'm told that the error percentage, mse and rmse values are low.

But when I plot the predictions, it just shows a linear function.

Any suggestions?

My architecture looks like:

df=pd.read_csv('DataGen(N=1,Gamma=0.1,Omega=5).csv')
dataset=df.values
X=dataset[:1800000,0].reshape(-1,1)
Y=dataset[:1800000,2].reshape(-1,1)
X2=dataset[1800001:,0].reshape(-1,1)
Y2=dataset[1800001:,2].reshape(-1,1)
scaler= MinMaxScaler(feature_range=(0,1))
X_min=scaler.fit_transform(X)
Y_min=scaler.fit_transform(Y.reshape(-1,1))

X_test=scaler.fit_transform(X2)
Y_test=scaler.fit_transform(Y2.reshape(-1,1))

seed=7
np.random.seed(seed)
X_tr,X_val, Y_tr, Y_val = train_test_split(X,Y,test_size=0.1, random_state=seed)

def NN():
model= Sequential()

return model


My plotted results look kind of like this:

The blue points are the expected values and the red points are predictions.

• What is your model architecture? Can we see some examples of inputs to your function and its respective output? – JahKnows Sep 8 '18 at 19:18
• Please recheck the question, I redited it now. Thanks – DeepLearner Sep 8 '18 at 20:20

My guess is that the problem is with your first layer: model.add(Dense(1, input_dim=1, activation='tanh',kernel_initializer = 'normal')). With a single hidden unit, a lot of information from the input layer will not be available to subsequent layers.
• If it were me, I'd start with one dense layer with 32 neurons. model= Sequential() model.add(Dense(32, input_dim=4, activation='relu') model.add(Dense(1, activation = None)) Then, I'd see if more or less neurons makes any difference. Then I would add another layer with 32 neurons, and repeat until I was happy with the result. A network with many layers is typically used with hierarchical relationships; with 4 inputs, I don't think you should require more than one or two layers. – from keras import michael Sep 8 '18 at 21:13