if (FALSE) demo(encoderSnnsCLib)
if (FALSE) demo(art1_lettersSnnsR)
if (FALSE) demo(art2_tetraSnnsR)
if (FALSE) demo(artmap_lettersSnnsR)
if (FALSE) demo(eight_elmanSnnsR)
if (FALSE) demo(rbf_irisSnnsR)
if (FALSE) demo(rbf_sinSnnsR)
if (FALSE) demo(rbfDDA_spiralsSnnsR)
if (FALSE) demo(som_cubeSnnsR)
#This is the demo eight_elmanSnnsR
#Here, we train an Elman network
#and save a trained and an untrained version
#to disk, as well as the used training data
basePath <- ("./")
data(snnsData)
inputs <- snnsData$eight_016.pat[,inputColumns(snnsData$eight_016.pat)]
outputs <- snnsData$eight_016.pat[,outputColumns(snnsData$eight_016.pat)]
snnsObject <- SnnsRObjectFactory()
snnsObject$setLearnFunc('JE_BP')
snnsObject$setUpdateFunc('JE_Order')
snnsObject$setUnitDefaults(1,0,1,0,1,'Act_Logistic','Out_Identity')
snnsObject$elman_createNet(c(2,8,2),c(1,1,1),FALSE)
patset <- snnsObject$createPatSet(inputs, outputs)
snnsObject$setCurrPatSet(patset$set_no)
snnsObject$initializeNet(c(1.0, -1.0, 0.3, 1.0, 0.5) )
snnsObject$shufflePatterns(TRUE)
snnsObject$DefTrainSubPat()
if (FALSE) snnsObject$saveNet(paste(basePath,"eight_elmanSnnsR_untrained.net",sep=""),
"eight_elmanSnnsR_untrained")
parameters <- c(0.2, 0, 0, 0, 0)
maxit <- 1000
error <- vector()
for(i in 1:maxit) {
res <- snnsObject$learnAllPatterns(parameters)
if(res[[1]] != 0) print(paste("Error at iteration ", i, " : ", res, sep=""))
error[i] <- res[[2]]
}
error[1:500]
plot(error, type="l")
if (FALSE) snnsObject$saveNet(paste(basePath,"eight_elmanSnnsR.net",sep=""),
"eight_elmanSnnsR")
if (FALSE) snnsObject$saveNewPatterns(paste(basePath,"eight_elmanSnnsR.pat",sep=""),
patset$set_no)
Run the code above in your browser using DataLab