# Regression loss function is nan

I'm a beginner with ANN and DL in general. I have a regression task with a target of 2-dimensions, my dataset only have 46 samples (small dataset I think). I tried the code below that does a regression with only one output which works normally.

When I change to a two dimensional regression, my loss function becomes equal to NaN. I tried to change the optimizer and fix the dropout rate, but nothing changed, any solution?

import numpy
import pandas
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Dropout
from keras.wrappers.scikit_learn import KerasRegressor
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import KFold
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline

dataframe.isnull().any()

dataset = dataframe.values

X = dataset[:, 0:5]
Y = dataset[:,5:7]

def baseline_model():
#create model
model = Sequential()
='relu'))

#compile model
return model

#fix random seed for reproducibility
seed = 7
numpy.random.seed(seed)

estimators=[]
estimators.append(('standardize', StandardScaler()))
estimators.append(('mlp', KerasRegressor(build_fn=baseline_model, epochs=50, batch_size=32, verbose=0)))
pipeline = Pipeline(estimators)

kfold = KFold(n_splits=10, random_state = seed)
results = cross_val_score(pipeline, X, Y, cv=kfold)

print ("Result: %.2f (%.2f) MSE" %(results.mean(), results.std()))

• NaN are sometimes due to too large learning rate. Try to set it 10 times lower, or so. Jan 21 '19 at 15:19
• I think your dataset is way too small. I guess your model have a big bias error and you are additionally using regurlarization, dropping 50% of neurons after the first hidden layer. Can you share your dataset?
– MaxU
Jan 21 '19 at 17:29