Hello,

Thanks for that. I've taken a look at the source code, and I see that  
the bulk of the processing is done in C, with R acting as a wrapper.  
Below is the function I think is doing the training in the network.

I'm guessing it's the standard Backpropagation with a decay term  
algorithm? Can anyone confirm if that's correct?

Cheers,
Wee-Jin

------------------------------------------------------------
void
VR_dfunc(double *p, double *df, double *fp)
{
     int   i, j;
     double sum1;

     for (i = 0; i < Nweights; i++)
	wts[i] = p[i];
     for (j = 0; j < Nweights; j++)
	Slopes[j] = 2 * Decay[j] * wts[j];
     TotalError = 0.0;
     for (i = 0; i < NTrain; i++) {
	for (j = 0; j < Noutputs; j++)
	    toutputs[j] = TrainOut[i + NTrain * j];
	fpass(TrainIn + i, toutputs, Weights[i], NTrain);
	bpass(toutputs, Weights[i]);
     }
     sum1 = 0.0;
     for (i = 0; i < Nweights; i++)
	sum1 += Decay[i] * p[i] * p[i];
     *fp = TotalError + sum1;
     for (j = 0; j < Nweights; j++)
	df[j] = Slopes[j];
     Epoch++;
}
-----------------------------------------


On 23 Nov 2006, at 07:36, Dieter Menne wrote:

> Wee-Jin Goh <wjgoh <at> brookes.ac.uk> writes:
>
>>
>> Just to add to this, I also need to know what language is the "nnet"
>> package written in? Is it in pure R or is it a wrapper for a C
>> library.
>
> As usual, you can download the full source to find out what you  
> want, but it's a
> bit hidden. Simply said, nnet (R+C) is part of package MASS is part  
> of bundle
> VR, and can be downloaded as a tar.gz from
>
> http://cran.at.r-project.org/src/contrib/Descriptions/VR.html
>
> (No private flames, please, in case I should have mixed up package  
> and bundle).
>
> /*  nnet/nnet.c by W. N. Venables and B. D. Ripley  Copyright (C)  
> 1992-2002
>  *
>  * weights are stored in order of their destination unit.
>  * the array Conn gives the source unit for the weight (0 = bias unit)
>  * the array Nconn gives the number of first weight connecting to  
> each unit,
>  * so the weights connecting to unit i are Nconn[i] ... Nconn[i+1]  
> - 1.
>  *
>  */
>
> #include <R.h>
> #include <R_ext/Applic.h>
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


	[[alternative HTML version deleted]]

