[R] passing arguments from nnet to optim

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Aug 26 17:49:58 CEST 2005


On Fri, 26 Aug 2005, Tarca, Adi wrote:

>
> Hi everyone,
> According to R reference manual, the nnet function uses the BFGS method
> of optim to optimize the neural network parameters.

What the help page says is

      ...: arguments passed to or from other methods.

That means methods of nnet().

      Optimization is done via the BFGS method of 'optim'.

but it is not calling optim, rather the C code implementing optim.

> I would like, when calling the function nnet to tell the optim function
> not to produce the tracing information on the progress of the
> optimization, or at least to reduce the frequency of the reports.
> I tried the following:
> a) nnet default
>> x<-rnorm(20)
>> y<-seq(0,1,length=20)
>> s<-nnet(y~x,size=1)
> # weights:  4
> initial  value 1.910932
> iter  10 value 1.819382
> iter  20 value 1.788736
> iter  30 value 1.775778
> iter  40 value 1.767771
> iter  50 value 1.765063
> iter  60 value 1.762631
> iter  70 value 1.760670
> iter  80 value 1.759349
> iter  90 value 1.757801
> iter 100 value 1.756290
> final  value 1.756290
> stopped after 100 iterations
>
> Report is generated at every 10 iterations.
>
> b) passing the REPORT parameter to optim via the control argument
>> x<-rnorm(20)
>> y<-seq(0,1,length=20)
>> s<-nnet(y~x,size=1,control=list(REPORT=50))
> # weights:  4
> initial  value 1.894905
> iter  10 value 1.672337
> iter  20 value 1.658612
> iter  30 value 1.654824
> iter  40 value 1.653465
> iter  50 value 1.652785
> iter  60 value 1.652343
> iter  70 value 1.652116
> iter  80 value 1.651860
> iter  90 value 1.651525
> iter 100 value 1.651292
> final  value 1.651292
> stopped after 100 iterations
>
> Is still producing reports at each 10 iterations.
> Has anyone an idea how can I turn off the report generation or at least
> to reduce its frequency?

You do it via the C code.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list