SnnsR-class | R Documentation |
An S4 class that is the main class of RSNNS. Each instance of this class contains a pointer to a C++ object of type SnnsCLib, i.e. an instance of the SNNS kernel.
The only slot variables
holds an environment with all member variables.
Currently, there are two members (constructed by the object factory):
A pointer to the corresponding C++ object
a serialization of the C++ object, in SNNS .net format
The member variables are not directly present as slots but wrapped in an environment to allow for changing the serialization (by call by reference).
An object of this class is used internally by all the models in the package.
The object is always accessible by model$snnsObject$...
To make full use of the SNNS functionalities, you might want to use this class directly.
Always use the object factory SnnsRObjectFactory
to construct an object,
and the calling mechanism $
to call functions. Through the calling mechanism,
many functions of SnnsCLib are present that are not documented here, but in the SNNS User
Manual. So, if you choose to use the low-level interface, it is highly recommended to have
a look at the demos and at the SNNS User Manual.
Zell, A. et al. (1998), 'SNNS Stuttgart Neural Network Simulator User Manual, Version 4.2', IPVR, University of Stuttgart and WSI, University of Tübingen. https://www.ra.cs.uni-tuebingen.de/SNNS/welcome.html
$
, SnnsRObjectFactory
## Not run: demo(encoderSnnsCLib)
## Not run: demo(art1_lettersSnnsR)
## Not run: demo(art2_tetraSnnsR)
## Not run: demo(artmap_lettersSnnsR)
## Not run: demo(eight_elmanSnnsR)
## Not run: demo(rbf_irisSnnsR)
## Not run: demo(rbf_sinSnnsR)
## Not run: demo(rbfDDA_spiralsSnnsR)
## Not run: 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()
## Not run: snnsObject$saveNet(paste(basePath,"eight_elmanSnnsR_untrained.net",sep=""),
"eight_elmanSnnsR_untrained")
## End(Not run)
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")
## Not run: snnsObject$saveNet(paste(basePath,"eight_elmanSnnsR.net",sep=""),
"eight_elmanSnnsR")
## End(Not run)
## Not run: snnsObject$saveNewPatterns(paste(basePath,"eight_elmanSnnsR.pat",sep=""),
patset$set_no)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.