[R] RSNNS neural network
David Winsemius
dwinsemius at comcast.net
Thu Mar 3 23:54:54 CET 2016
> On Mar 3, 2016, at 12:33 PM, jake88 <youtube_b at telus.net> wrote:
>
> Data set attached … rename to mydata.csv .
>
>
>
>
>
> require ( RSNNS )
> mydata = read.csv("mydata.csv",header = TRUE)
# Needed to change to mydata.txt
>
> mydata.train = mydata[3000:10000,]
>
> mydata.test = mydata[10005:10006,]
>
> myfit <- elman ( mydata.train[,2:19],mydata.train[,1], size =100 , learnFuncParams =c (0.1) , maxit =1000)
>
> pred <-predict (myfit , mydata.test[,2:19])
>
>
>
> On Tue, Mar 1, 2016 at 12:35 AM, jake88 <youtube_b at telus.net> wrote:
>
> I am new to R and neural networks . So I trained and predicted an elman
> network like so :
>
> require ( RSNNS )
> mydata = read.csv("mydata.csv",header = TRUE)
> mydata.train = mydata[1000:2000,]
> mydata.test = mydata[800:999,]
>
> fit <- elman ( mydata.train[,2:10],mydata.train[,1], size =100
> learnFuncParams =c (0.1) , maxit =1000)
> pred <-predict (fit , mydata.test[,2:10])
>
> So pred contains the predictions .
> The problem I am having is that when I run pred <-predict (fit ,
> mydata.test[1,2:10]) repeatedly , it gives me different results each time .
> Should not the weights and bias be set permanently in the network and give
> the same result everytime ?
>
>
I get "different" results with each call as well, but I do also observe that the differences are generally in the 6th or 7th decimal place.
rbind( t( predict (fit , mydata.test[,2:10])), t( predict (fit , mydata.test[,2:10])))
800 801 802 803 804 805 806 807
[1,] 0.006875724 0.004711885 0.006329221 0.007906904 0.005760470 0.005573335 0.005393596 0.004476394
[2,] 0.006875725 0.004711647 0.006329220 0.007906901 0.005760474 0.005573337 0.005394077 0.004476394
808 809 810 811 812 813 814 815
[1,] 0.004994765 0.006582610 0.005095046 0.001079763 -0.001370882 0.006502322 0.0003687060 -0.0004826686
[2,] 0.004994765 0.006582132 0.005094331 0.001079763 -0.001370883 0.006502321 0.0003687064 -0.0004829080
Maybe the network is "thinking different" each time on my Mac?
--
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list