Cons of setting MaxNWts in R nnet to a very large number

2.9k views Asked by At

I am using the nnet function package from the nnet package in R. I am trying to set the MaxNWts parameter and was wondering if there is any disadvantage to setting this number to a large value like 10^8 etc. The documentation says

"The maximum allowable number of weights. There is no intrinsic limit in the code, but increasing MaxNWts will probably allow fits that are very slow and time-consuming."

I also calculate the size parameter by the following calculation

size = Math.Sqrt(%No of Input Nodes% * %No of Output Nodes%)

The problem is that if I set "MaxNWts" to a value like 10000 , it fails sometimes because the number of coefficients is > 10000 when working with huge data sets.

EDIT

Is there a way to calculate the number of wts( to the get the same number calculated by R nnet) somehow so that I can explicitly set it every time without worrying about the failures?

Suggestions?

1

There are 1 answers

2
doctorate On

This is what I have seen in the Applied Predictive Modeling: Kuhn M, Johnson K. Applied predictive modeling. 1st edition. New York: Springer. 2013. for the MaxNWts= argument you can pass either one of:

5 * (ncol(predictors) + 1) + 5 + 1)

or

10 * (ncol(predictors) + 1) + 10 + 1  

or

13 * (ncol(predictors) + 1) + 13 + 1

predictors is the matrix of your predictors

I think it is empirical based on your data, it is a regularization term like the idea behind shrinkage methods, ridge regression (L2) term for instance. It's main goal is to prevent the model from over fitting as is the case often with neural networks because of the over-parameterization of its computation.