I want to train a neural network with the neuralnet package in R - but without using bias nodes.
I think I should somehow use the exclude argument for that but I don't know how.
My question
How do I e.g. train a model with 6 input neurons, 3 hidden neurons and 7 output neurons - but without any bias neurons?
The logic is as follows:
It starts with the first bias neuron, then the first input neuron, the second input neuron and so forth.
When you got through all input neurons the next layer comes, starting again with the bias neuron, then the first hidden neuron, the second hidden neuron and so forth.
In the above case this gives: exclude = c(1, 8, 15, 22, 26, 30, 34, 38, 42, 46)
Using exclude works, but it creates problems for predict.
exclude introduces "NA" in weights, which causes predict to return "NA".
Manual workaround, set NA weights to zeros: nn$weights = lapply(nn$weights, lapply, function(x) replace(x, is.na(x), 0))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With