'How to create a series of neural networks using neuralnet in R?
I would like to change this:
library(neuralnet)
nn1 <- neuralnet(Species == "setosa" ~ Petal.Length + Petal.Width, iris, linear.output = FALSE)
nn1 <- neuralnet(Species == "setosa" ~ Petal.Length + Petal.Width, iris, linear.output = FALSE)
into something like this:
nn[1] <- neuralnet(Species == "setosa" ~ Petal.Length + Petal.Width, iris, linear.output = FALSE)
nn[2] <- neuralnet(Species == "setosa" ~ Petal.Length + Petal.Width, iris, linear.output = FALSE)
neuralnet creates networks as lists. I have tried creating a list of lists like this:
AllNets <- list(nn1, nn2)
But when I try go back to use a particular network it doesn't behave like a neural network although I can't see any difference using str():
plot(AllNets[2])
nntemp = AllNets[2]
nntemp = unlist(AllNets[2])
nntemp = unlist(AllNets[2], recursive = FALSE)
plot(nntemp)
Can anyone please advise?
Solution 1:[1]
I needed double bracket notation:
plot(AllNets[[2]]) will work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ThomasC |
