Waldir de Carvalho Junior
2012-Mar-01 15:56 UTC
[R] how to change or copy to another the names of models
Hi I would like to know how I can change the name of a model for each trainning cycle of a model. I work with the RSNNS package and to build a neural network, I used : for (i in 5:30) .... model_ANN <- mlp(X, Y, size=n,....) # where size is the number of neurons in the hidden layer but I need to save each time that the model that is build (the end of each cycle), e.g., when i = 5, I need to save the model with a especific name, when i = 6, also I need to save the model with another name How i am doing, i am saving only the last model with n = 30 and with the name "model_ANN" Question how can I change the name of the model (model_ANN) at each end of cycle of i values? I have already tryied "copy, save, rename,.........." but unsuccessfully thanks for any answer -- ________________________ Waldir de Carvalho Junior Pedologia/Pedologue Pesquisador/Chercheur Embrapa Solos/INRA - UMR- LISAH [[alternative HTML version deleted]]
Jeff Newmiller
2012-Mar-01 22:17 UTC
[R] how to change or copy to another the names of models
A) you will generally get a better response when your question includes
reproducible code/sample data, and a clear identification of the desired final
result.
B) in most cases like this, a proliferation of names is not as useful as the OP
(you) thinks it is. Much better is to build a list of results that can be
indexed by position or by name.
mymodel <- vector( "list", 30 )
for (i in 5:30) {
mymodel[[i]] <- mlp(X, Y, size=n,....)
}
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live
Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
Waldir de Carvalho Junior <waldircj at gmail.com> wrote:
>Hi
>I would like to know how I can change the name of a model for each
>trainning cycle of a model.
>I work with the RSNNS package and to build a neural network, I used :
>for (i in 5:30) ....
>model_ANN <- mlp(X, Y, size=n,....) # where size is the number of
>neurons
>in the hidden layer
>but I need to save each time that the model that is build (the end of
>each
>cycle), e.g., when i = 5, I need to save the model with a especific
>name,
>when i = 6, also I need to save the model with another name
>How i am doing, i am saving only the last model with n = 30 and with
>the
>name "model_ANN"
>Question
>how can I change the name of the model (model_ANN) at each end of cycle
>of
>i values?
>I have already tryied "copy, save, rename,.........." but
>unsuccessfully
>thanks for any answer
>
>--
>________________________
>Waldir de Carvalho Junior
>Pedologia/Pedologue
>Pesquisador/Chercheur
>Embrapa Solos/INRA - UMR- LISAH
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
Waldir de Carvalho Junior
2012-Mar-02 13:36 UTC
[R] how to change or copy to another the names of models
Hi help-list
I try to better explain my problem.
My problem is below. For each cycle of (n) I need to save the model
(model.mlp), because the neuralnet is unique and when I had choose the best
architecture of the neuralnet, and need the neuralnet (the model.mlp) that
has already been trainned.
I can´t train again, because the result will be not the same.
I thought that I can put a line at the end of the cycles to copy the
"model.mlp" to another name and save it as a model for each one of the
cycle.
I hope I have better explain my problem.
thanks in advance
##############################
# built a model "mlp" (neuralnet) and training it changing the number
of
hidden neurons (1 a 30)
for (n in 1:30) {
print(n)
model.mlp <- mlp(padroes$inputsTrain, padroes$targetsTrain, size = n,
initFunc="Randomize_Weights",
initFuncParams=c(-0.5, 0.5),
learnFunc="Std_Backpropagation",
learnFuncParams = c(0.2, 0.1),
updateFunc="Topological_Order",
hiddenActFunc="Act_Logistic",
shufflePatterns=TRUE, linOut=TRUE,
maxit = 3000, inputsTest = padroes$inputsTest, targetsTest
padroes$targetsTest)
}
########################################
2012/3/1 Waldir de Carvalho Junior <waldircj@gmail.com>
> Hi
> I would like to know how I can change the name of a model for each
> trainning cycle of a model.
> I work with the RSNNS package and to build a neural network, I used :
> for (i in 5:30) ....
> model_ANN <- mlp(X, Y, size=n,....) # where size is the number of
neurons
> in the hidden layer
> but I need to save each time that the model that is build (the end of each
> cycle), e.g., when i = 5, I need to save the model with a especific name,
> when i = 6, also I need to save the model with another name
> How i am doing, i am saving only the last model with n = 30 and with the
> name "model_ANN"
> Question
> how can I change the name of the model (model_ANN) at each end of cycle of
> i values?
> I have already tryied "copy, save, rename,.........." but
unsuccessfully
> thanks for any answer
>
--
________________________
Waldir de Carvalho Junior
Pedologia/Pedologue
Pesquisador/Chercheur
Embrapa Solos/INRA - UMR- LISAH
[[alternative HTML version deleted]]
kees duineveld
2012-Mar-02 13:52 UTC
[R] how to change or copy to another the names of models
Hi Waldir I think this is easier via an lappy() lapply(1:30, function(x) mlp(...your settings here, including size=x...) ) Regards, Kees On Fri, Mar 2, 2012 at 2:36 PM, Waldir de Carvalho Junior <waldircj at gmail.com> wrote:> Hi help-list > I try to better explain my problem. > My problem is below. For each cycle of (n) I need to save the model > (model.mlp), because the neuralnet is unique and when I had choose the best > architecture of the neuralnet, and need the neuralnet (the model.mlp) that > has already been trainned. > I can?t train again, because the result will be not the same. > I thought that I can put a line at the end of the cycles to copy the > "model.mlp" to another name and save it as a model for each one of the > cycle. > I hope I have better explain my problem. > thanks in advance > ############################## > > # built a model ?"mlp" (neuralnet) and training it changing the number of > hidden neurons (1 a 30) > for (n in 1:30) { > print(n) > model.mlp <- ?mlp(padroes$inputsTrain, padroes$targetsTrain, size = n, > initFunc="Randomize_Weights", > ? ? ? ? ? ? ?initFuncParams=c(-0.5, 0.5), learnFunc="Std_Backpropagation", > learnFuncParams = c(0.2, 0.1), > ? ? ? ? ? ? ?updateFunc="Topological_Order", hiddenActFunc="Act_Logistic", > shufflePatterns=TRUE, linOut=TRUE, > ? ? ? ? ? ? ?maxit = 3000, inputsTest = padroes$inputsTest, targetsTest > padroes$targetsTest) > } > ######################################## > > > 2012/3/1 Waldir de Carvalho Junior <waldircj at gmail.com> > >> Hi >> I would like to know how I can change the name of a model for each >> trainning cycle of a model. >> I work with the RSNNS package and to build a neural network, I used : >> for (i in 5:30) .... >> model_ANN <- mlp(X, Y, size=n,....) # where size is the number of neurons >> in the hidden layer >> but I need to save each time that the model that is build (the end of each >> cycle), e.g., when i = 5, I need to save the model with a especific name, >> when i = 6, also I need to save the model with another name >> How i am doing, i am saving only the last model with n = 30 and with the >> name "model_ANN" >> Question >> how can I change the name of the model (model_ANN) at each end of cycle of >> i values? >> I have already tryied "copy, save, rename,.........." but unsuccessfully >> thanks for any answer >> > > -- > ________________________ > Waldir de Carvalho Junior > Pedologia/Pedologue > Pesquisador/Chercheur > Embrapa Solos/INRA - UMR- LISAH > > ? ? ? ?[[alternative HTML version deleted]] > > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >