简体   繁体   English

如何使用Neuronet包初始化权重?

[英]how to initialize weights with the neuralnet package?

I am using the neuralnet package in R, but I have a problem when I want to initialize certain number of initial weights for my network. 我在R中使用Neuronet软件包,但是当我想为网络初始化一定数量的初始权重时遇到问题。 I have tried to do it based on the results that I got from the default random weights generated, but no luck at all. 我尝试根据从默认的随机权重生成的结果中得出的结果来做,但是一点都不幸运。

This is the part where I should put the initial weights: 这是我应该初始权重的部分:

weigths<-c(-0.3,0.2,
    0.2,0.05,
    0,2,-0.1,
    -0.1,0.2,0.2)
net=neuralnet(to~x1+x2,tdata,hidden=2,threshold=0.01,constant.weights=weights) 

because I am considering that the weights follow this pattern: 因为我正在考虑权重遵循以下模式:

Intercept.to.1layhid1  -5.0556934519949
x1.to.1layhid1         10.9208362719511
x2.to.1layhid1         12.9996270590530
Intercept.to.1layhid2   3.7047601228351
x1.to.1layhid2         -2.5636252939619
x2.to.1layhid2         -2.5759077405754
Intercept.to.to        -1.6494794336705
1layhid.1.to.to         1.3502874764968
1layhid.2.to.to         1.6969811621181

but when I apply it I got the error: 但是当我应用它时,我得到了错误:

Error in constant.weights != 0

Any help? 有什么帮助吗?

Thanks 谢谢

You are looking for the startweights argument to initialize custom weights. 您正在寻找startweights参数来初始化自定义权重。 This is in the documentation: 在文档中:

help(neuralnet)

startweights:
  a vector containing starting values for the weights. 
  The weights will not be randomly initialized.

The constant.weights is used to specify fixed weights those which you would have excluded with the exclude agrument. constant.weights用于指定固定的权重,这些权重是您通过exclude聚合来exclude

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM