user723556
user723556

Reputation:

MATLAB - gradient in neural network starting from NaN?

I was trying to use the neural network tool in MATLAB 2011.

I have come across a very weird problem.

I just used the GUI of the neural network to feed my inputs and everything.

My gradient of the neural network is NaN while it gets initialized.

The neural network stops in 1 iteration. ( which I am guessing is because of the gradient being NaN).

As far as my understanding of the NN goes, the gradient isn't supposed to be NaN.

I did check up things using the script mode.

The hidden layer size was 25. (Tried changing this, no effect. Didn't expect it to be, but just in case.)

The default function of trainlm was being used.

It was set to 80/10/10 split for training/validation/testing. (Played around with this too.)

The maximum stopping epochs were set to 1000. Validation iterations that are needed (for the continous check, was set to 6 the default).

So any idea, why my gradient is coming to be NaN? Any help is much appreciated!

Upvotes: 0

Views: 1582

Answers (1)

Amro
Amro

Reputation: 124563

Check that the input data doesn't have NaN in it:

any(isnan(inputData(:)))

Also make sure that your preprocessing step (data normalization for example), doesn't introduce NaN values (dividing by zero for example)

Upvotes: 1

Related Questions