Reputation: 3477
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. 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
Upvotes: 1
Views: 2672
Reputation: 19960
You are looking for the startweights
argument to initialize custom weights. 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.
Upvotes: 3