Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Configure neural network without train

Subject: Configure neural network without train

From: Rafael

Date: 9 Aug, 2012 15:30:22

Message: 1 of 5

Hello,

I'm treating with dynamic recurrent neural networks, NARX in my case, and my objective is to adjust the parameters with genetic algorithm. Therefore I am not using the 'train' command, but I have to configure the network by hand (either manually or with the 'configure' command) and handle the weights and bias vectors with 'getwb' and 'setwb'. The problem I'm encountering is that I can't set and retrieve the networks parameters because I think the net is not getting correctly configured.

I'm trying with the net configuration in two ways, the first one manually (assigning input and output sizes and ranges, input preprocessing settings and output postprocessing settings), I do this by typing:

        nn.inputs{1}.exampleInput = nnDataIn;
        nn.inputs{2}.exampleInput = nnDataOut;

(The net has 2 input sources because it's in open loop at the moment)

And althought I got correct inputs and output sizes, ranges and I can initialize the weights using 'init' with success; I can't get or set them with 'getwb' or 'setwb'. I get this error:

        SWITCH expression must be a scalar or string constant.

        Error in network/subsref (line 140)
                switch (subs)

        Error in getwb (line 22)
        inputLearn = net.hint.inputLearn;

I tried to configure the net in another way with the 'configure' command:

        nn = configure(nn, nnDataIn, nnDataOut);

But I get this error:

        Error using network/configure (line 111)
        The numbers of input signals and networks inputs do not match.

I guess it's because the net has 2 input sources and I'm passing only 1 input signal and the target signal, but I don't know how to use 'configure' in another way.

When I try with the closed-loop version of the net, the story changes a bit only, I can't configure it in such a way that I could handle the parameters vectors with 'getwb' or 'setwb'. But if I use the 'configure' exactly in the same way that with the open-loop version, then it doesn't return any error (I guess it's because this net has only 1 input signal and the 'configure' command is executed in a proper way).

Could you tell me how could I configure correctly the first net? A dynamic recurrent neural network (NARX) in open loop mode that has 2 input sources and 1 output.

And I wanted to ask you one more thing related to this configuration process: If I configure the net in this way with sample data, will I have problems with the simulation (I won't use 'train') if I use another sample data? I mean with the normalization process and the process settings, or the net reconfigures the ranges each time a simulation is done?

Thanks you in advance.

Regards,
Rafael

Subject: Configure neural network without train

From: Rafael

Date: 10 Aug, 2012 11:56:12

Message: 2 of 5

Any idea please?

Subject: Configure neural network without train

From: Greg Heath

Date: 22 Aug, 2012 19:25:08

Message: 3 of 5

"Rafael" wrote in message <k00l2e$gt$1@newscl01ah.mathworks.com>...
> Hello,
>
> I'm treating with dynamic recurrent neural networks, NARX in my case, and my objective is to adjust the parameters with genetic algorithm. Therefore I am not using the 'train' command, but I have to configure the network by hand (either manually or with the 'configure' command) and handle the weights and bias vectors with 'getwb' >and 'setwb'.

You don't have to use those functions. Access them directly. For examples search

heath net.IW net.LW net.b

Hope this helps.

Greg

Subject: Configure neural network without train

From: Greg Heath

Date: 8 Jan, 2013 08:18:16

Message: 4 of 5

"Rafael" wrote in message <k00l2e$gt$1@newscl01ah.mathworks.com>...
> Hello,
>
> I'm treating with dynamic recurrent neural networks, NARX in my case, and my objective is to adjust the parameters with genetic algorithm. Therefore I am not using the 'train' command, but I have to configure the network by hand (either manually or with the 'configure' command) and handle the weights and bias vectors with 'getwb' and 'setwb'. The problem I'm encountering is that I can't set and retrieve the networks parameters because I think the net is not getting correctly configured.
>
> I'm trying with the net configuration in two ways, the first one manually (assigning input and output sizes and ranges, input preprocessing settings and output postprocessing settings), I do this by typing:
>
> nn.inputs{1}.exampleInput = nnDataIn;
> nn.inputs{2}.exampleInput = nnDataOut;
>
> (The net has 2 input sources because it's in open loop at the moment)

Doesn't the output have to be delayed?
 
> And althought I got correct inputs and output sizes, ranges and I can initialize the weights using 'init' with success; I can't get or set them with 'getwb' or 'setwb'.

In an earlier post I suggested using the direct commands

IW = net.IW
LW = net.LW
b = net.b

instead of getwb and vice versa instead of setwb.
 
> I tried to configure the net in another way with the 'configure' command:
>
> nn = configure(nn, nnDataIn, nnDataOut);
>
> But I get this error:
>
> Error using network/configure (line 111)
> The numbers of input signals and networks inputs do not match.
>
> I guess it's because the net has 2 input sources and I'm passing only 1 input signal and the target signal, but I don't know how to use 'configure' in another way.

Use a delayed version of the output to add another input.

> When I try with the closed-loop version of the net, the story changes a bit only, I can't configure it in such a way that I could handle the parameters vectors with 'getwb' or 'setwb'. But if I use the 'configure' exactly in the same way that with the open-loop version, then it doesn't return any error (I guess it's because this net has only 1 input signal and the 'configure' command is executed in a proper way).
>
> Could you tell me how could I configure correctly the first net? A dynamic recurrent neural network (NARX) in open loop mode that has 2 input sources and 1 output.

See above.
 
> And I wanted to ask you one more thing related to this configuration process: If I configure the net in this way with sample data, will I have problems with the simulation (I won't use 'train') if I use another sample data? I mean with the normalization process and the process settings, or the net reconfigures the ranges each time a simulation is done?

The summary statistics of the other sample data must be reasonably close. The normalization is done automatically.

Hope this helps.

Greg

Subject: Configure neural network without train

From: Greg Heath

Date: 14 Feb, 2013 09:05:08

Message: 5 of 5

"Rafael" wrote in message <k00l2e$gt$1@newscl01ah.mathworks.com>...
> Hello,
>
> I'm treating with dynamic recurrent neural networks, NARX in my case, and my objective is to adjust the parameters with genetic algorithm. Therefore I am not using the 'train' command, but I have to configure the network by hand (either manually or with the 'configure' command) and handle the weights and bias vectors with 'getwb' and 'setwb'. The problem I'm encountering is that I can't set and retrieve the networks parameters >because I think the net is not getting correctly configured.

Use preparets before configure.

Hope this helps.

Greg
 

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us