NaN Loss and Quantity of Data

Viewed 23

everyone.

While I was training a neural network with a training dataset of 40000 objects, I was having problems related to the loss function being equal to Nan at each epoch. After sampling the dataset, using 50% of it, this problem wasn't occurring any more. I was wondering how the size of the training data would have an impact in this setting. I used the following function to do the training:

def train_test_net_notLinearCDF(X,y,coefficient,test_input):

  # Neural network
  model = Sequential()
  model.add(Dense(80, activation="relu", input_dim=X.shape[1]))
  model.add(Dense(20, activation="tanh"))
 
  model.add(Dense(1, activation="linear"))

  opt_adam = Adam(clipvalue=0.5)

  model.compile(loss='mean_squared_error', optimizer=opt_adam)

  history = model.fit(X, y, epochs=100, validation_split = 0.2,batch_size=32)

  fig1 = plt.gcf()
  plt.plot(history.history['loss'])
  plt.plot(history.history['val_loss'])
  plt.suptitle('MSE de treino e Validação ' + coefficient)
  plt.ylabel('MSE')
  plt.xlabel('Epoch')
  plt.legend(['Train', 'Val'], loc='upper left')
  plt.show()
  fig1.savefig('losses_varying_alpha_'+coefficient+'.png', dpi=300)


  y_pred = model.predict(test_input)

  return y_pred

Thanks in advance.

0 Answers
Related