Matrix size of layer weights in neural network(Er​ror:net.LW​{2,1} must be a 0-by-3 matrix.)

10 次查看(过去 30 天)
Hello, I had a Elman network with 3 hidden layers, 3 input layers and 1 output layer. I try to initial the hidden layer weights with a decent trained result which is saved before. But when I re-input the hidden layer weights into the network. Errors always bumped out. Error:net.LW{2,1} must be a 0-by-3 matrix. The error also happened when I valued the bias and input layer weights. I have two questions: (1) What does "0-by-3 matrix" mean? Does it mean the matrix should be a empty matrix? (2) I got the hidden layer weights, input layer weights and bias from the trainning result. Why it doesn't work when I re-input them into the network? They were saved in ".mat" format. They were all "cell" structure.
*%Code for saving the trainning result
iw = net.iw; % "iw" is variable of input layer weight
lw = net.lw; % "lw" is variable of hidden layer weight
theta = net.b; % "theta" is variable of bias
*%%Code for re-input the result
net.b{1} = theta{1,1};
net.lw{2,1} = lw{2,1};
net.iw{1,1} = iw{1,1};
net.b{2} = theta{2,1};
>> net.lw{2,1}
ans =
Empty matrix: 0-by-3
>> lw{2,1} % saved trainning result of hidden layer weight (variable "lw")
ans =
-1.3208 -1.4288 -0.7487
>> net.iw{1,1}
ans =
Empty matrix: 3-by-0
>> iw{1,1} % saved trainning result of input layer weight (variable "iw")
ans =
0.7936 0.7638 0.6892
-0.0306 -0.3250 -0.0438
0.8408 -1.0601 -0.9286
*
Error: network/subsasgn>network_subsasgn (line 553)
net.LW{2,1} must be a 0-by-3 matrix.
Error: network/subsasgn (line 13)
net = network_subsasgn(net,subscripts,v,netname);
Error: elman_PepperHTHS_v2 (line 65)
net.lw{2,1} = lw{2,1};
*
I can value net.b{1} successfuly but not the other three. That confused me a lot. If it could be answered, that would be appreciated so much.

回答(1 个)

Greg Heath
Greg Heath 2016-8-30
Hello, I had a Elman network with 3 hidden layers, 3 input layers and 1 output layer.
This makes no sense. Do you mean
Hello, I had a Elman network with 3 hidden nodes, 3 input nodes and 1 output node?
In addition, you never defined "net"
You'd be better off posting your code rather than trying to explain it.
Hope this helps.
Greg

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by