How to copy/clone RSNNS network in R? -


i create multiple copies of network instance predict mutliple independent waves. unfortunately simple reassigning not work in case, can do?

i attached reproducible demo shows results of predictions of both copies should same, not:

library(rsnns) points = sin(seq(1,20,0.1)) input = head(points,-1) output = tail(points,-1) net = elman(input, output, maxit=1000) netcopy1 = net netcopy2 = net print(predict(netcopy1, as.matrix(input[1:10]))) print(predict(netcopy2, as.matrix(input[1:10]))) 

the rsnns models c++ objects, why copying r pointer doesn't work. deep-copy such model, rsnns has object serialization mechanism. easiest way use save model disk , load it, e.g. follows:

library(rsnns)  set.seed(10)  points = sin(seq(1,20,0.1)) input = head(points,-1) output = tail(points,-1) net = elman(input, output, maxit=1000) netcopy1 = net  saverds(net, file="./net.rdata") netcopy2 = readrds("./net.rdata")  print(predict(netcopy1, as.matrix(input[1:10]))) print(predict(netcopy2, as.matrix(input[1:10]))) 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -