[R] R-help Digest, Vol 212, Issue 12

Dan Ryan D@n@Ry@n @end|ng |rom unbc@c@
Wed Oct 14 17:45:29 CEST 2020


Dear Frauke,

Thank you very much for taking the time to respond.  

You explanation was very helpful, and I now have that part figured out!

Best Wishes,

Dan

Frauke
Message: 3
Date: Mon, 12 Oct 2020 08:33:44 +0200 (CEST)
From: =?UTF-8?Q?Frauke_G=C3=BCnther?= <guenther using leibniz-bips.de>
To: "r-help using r-project.org" <r-help using r-project.org>
Cc: William Michels <wjm1 using caa.columbia.edu>, "smm using posteo.org"
        <smm using posteo.org>
Subject: Re: [R]  Fwd:  Help using the exclude option in the neuralnet
        package
Message-ID: <957726669.124476.1602484424752 using srvmail.bips.eu>
Content-Type: text/plain; charset="utf-8"

Dear all,

the exclude and constant.weights options are used as follows:

exclude: A matrix with n rows and 3 columns will exclude n weights. The the first column refers to the layer, the second column to the input neuron and the third column to the output neuron of the weight.

constant.weights: A vector specifying the values of the weights that are excluded from the training process and treated as fix.

Please refer to the following example:

Not using exclude and constant.weights (all weights are trained):

> nn <- neuralnet(Species == "setosa" ~ Petal.Length + Petal.Width, 
> iris, linear.output = FALSE)
>
> nn$weights
[[1]]
[[1]][[1]]
[,1]
[1,] 6.513239
[2,] -0.815920
[3,] -5.859802
[[1]][[2]]
[,1]
[1,] -4.597934
[2,] 9.179436

Using exclude (2 weights are excluded --> NA):

> nn <- neuralnet(Species == "setosa" ~ Petal.Length + Petal.Width, 
> iris, linear.output = FALSE,
exclude = matrix(c(1,2,1, 2,2,1),byrow=T, nrow=2))
> nn$weights
[[1]]
[[1]][[1]]
[,1]
[1,] -0.2815942
[2,] NA
[3,] 0.2481212
[[1]][[2]]
[,1]
[1,] -0.6934932
[2,] NA

Using exclude and constant.weights (2 weights are excluded and treated as fix --> 100 and 1000, respectively):

> nn <- neuralnet(Species == "setosa" ~ Petal.Length + Petal.Width, 
> iris, linear.output = FALSE,
exclude = matrix(c(1,2,1, 2,2,1),byrow=T, nrow=2),
constant.weights=c(100,1000))
> nn$weights
[[1]]
[[1]][[1]]
[,1]
[1,] 0.554119
[2,] 100.000000
[3,] 1.153611
[[1]][[2]]
[,1]
[1,] -0.3962524
[2,] 1000.0000000

I hope you will find this example helpful.

Sincerely,
Frauke


>     William Michels <wjm1 using caa.columbia.edu mailto:wjm1 using caa.columbia.edu > hat am 10.10.2020 18:16 geschrieben:
>
>
>     Forwarding: Question re "neuralnet" package on the R-Help mailing list:
>
>     https://stat.ethz.ch/pipermail/r-help/2020-October/469020.html
>
>     If you are so inclined, please reply to:
>
>     r-help using r-project.org mailto:r-help using r-project.org 
> <r-help using r-project.org mailto:r-help using r-project.org >
>
>     ---------- Forwarded message ---------
>     From: Dan Ryan <Dan.Ryan using unbc.ca mailto:Dan.Ryan using unbc.ca >
>     Date: Fri, Oct 9, 2020 at 3:52 PM
>     Subject: Re: [R] Help using the exclude option in the neuralnet package
>     To: r-help using r-project.org mailto:r-help using r-project.org 
> <r-help using r-project.org mailto:r-help using r-project.org >
>
>     Good Morning,
>
>     I am using the neuralnet package in R, and am able to produce some
>     basic neural nets, and use the output.
>
>     I would like to exclude some of the weights and biases from the
>     iteration process and fix their values.
>
>     However I do not seem to be able to correctly define the exclude and
>     constant.weights vectors.
>
>     Question: Can someone point me to an example where exclude and
>     contant.weights are used. I have search the R help archive, and
>     haven't found any examples which use these on the web.
>
>     Thank you in advance for any help.
>
>     Sincerely
>
>     Dan
>
>     [[alternative HTML version deleted]]
>
>     ______________________________________________
>     R-help using r-project.org mailto:R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>     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]]





More information about the R-help mailing list