Skip to content

Neuralnet Error

1 message · arun

#
Hi,

I am glad it is solved.

#ir3 <- data.frame(rbind(ir1[1:4],ir2))

should be "cbind" in your previous code.
Even if that was corrected, 


n<- neuralnet(Output~Sepal.Length+Sepal.Width+Petal.Length+Petal.Width,data=ir3,err.fct="sse",hidden=c(3),linear.output=FALSE)
Error in neurons[[i]] %*% weights[[i]] : 
? requires numeric/complex matrix/vector arguments
#Probably due to:
?str(ir3)
'data.frame':??? 150 obs. of? 6 variables:
?$ Sepal.Length: num? 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
?$ Sepal.Width : num? 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
?$ Petal.Length: num? 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
?$ Petal.Width : num? 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
?$ Species???? : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
?$ Output????? : Factor w/ 3 levels "","0","1": 3 3 3 3 3 3 3 3 3 3 ...
# my dataset 

str(iris1)
----------------
?$ Output????? : num? 1 1 1 1 1 1 1 1 1 1 ...
Your new str()
?str(ir4)
?num [1:150, 1:5] 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
?- attr(*, "dimnames")=List of 2
? ..$ : NULL
? ..$ : chr [1:5] "Sepal.Length" "Sepal.Width" "Petal.Width" "Petal.Length" ...
#Matrix/numeric/vector arguments are allowed.
#The result.matrix of your new code is different from that I got.? May be because you left out "virginica".
?n$result.matrix
??????????????????????????????????????? 1
error??????????????????? 125.007861173323
reached.threshold????????? 0.007860966751
steps???????????????????? 29.000000000000
Intercept.to.1layhid1????? 0.522166529273
Sepal.Length.to.1layhid1?? 1.491041058746
Sepal.Width.to.1layhid1?? -0.544345459033
Petal.Length.to.1layhid1? -0.615294328176
Petal.Width.to.1layhid1??? 3.734627433294
Intercept.to.1layhid2????? 3.633493428721
Sepal.Length.to.1layhid2?? 2.124216647102
Sepal.Width.to.1layhid2??? 2.029136986941
Petal.Length.to.1layhid2?? 2.181854757855
Petal.Width.to.1layhid2??? 3.410291043541
Intercept.to.1layhid3????? 0.603689174589
Sepal.Length.to.1layhid3?? 2.665300953113
Sepal.Width.to.1layhid3??? 1.322847578383
Petal.Length.to.1layhid3?? 1.897467378865
Petal.Width.to.1layhid3??? 3.275017257909
Intercept.to.Output??????? 2.345020538556
1layhid.1.to.Output??????? 1.642408665201
1layhid.2.to.Output??????? 3.552359709094
1layhid.3.to.Output??????? 2.319432740042

I am not sure which one is correct.? May be its with the vectorization.? 
So, I tried that,
Sepal.Length<-c(iris1$Sepal.Length)
?Sepal.Width<-c(iris1$Sepal.Width)
?Petal.Width<-c(iris1$Petal.Width)
?Petal.Length<-c(iris1$Petal.Length)

Output<-c(iris1$Output)
?iris2<-cbind(Sepal.Length,Sepal.Width,Petal.Width,Petal.Length,Output)> n3<-neuralnet(Output~Sepal.Length+Sepal.Width+Petal.Length+Petal.Width,data=iris2,err.fct="sse",hidden=c(3),linear.output=FALSE)
n3$result.matrix
?????????????????????????????????????? 1
error???????????????????? 0.014412178415
reached.threshold???????? 0.009527746351
steps??????????????????? 45.000000000000
Intercept.to.1layhid1???? 4.563970987648
Sepal.Length.to.1layhid1? 4.070751169463
Sepal.Width.to.1layhid1?? 2.994119258844
Petal.Length.to.1layhid1? 4.926769597100
Petal.Width.to.1layhid1?? 2.823718327794
Intercept.to.1layhid2??? -1.280594422741
Sepal.Length.to.1layhid2? 0.635447411640
Sepal.Width.to.1layhid2? -3.621227214142
Petal.Length.to.1layhid2? 2.426457019767
Petal.Width.to.1layhid2?? 2.238558775899
Intercept.to.1layhid3??? -1.808205462130
Sepal.Length.to.1layhid3 -0.645677082354
Sepal.Width.to.1layhid3? -1.463897594407
Petal.Length.to.1layhid3? 2.257667858752
Petal.Width.to.1layhid3?? 4.055657058740
Intercept.to.Output?????? 1.426771691174
1layhid.1.to.Output?????? 2.525255850764
1layhid.2.to.Output????? -4.115814022250
1layhid.3.to.Output????? -4.492878425478

Slightly different than the one I got before.? 

A.K.