Weight and Bias from a Neural Network

58 visualizaciones (últimos 30 días)
massimiliano de martino
massimiliano de martino el 6 de Abr. de 2018
Comentada: KAE el 9 de Oct. de 2018
Hello to everybody, I'm using Neural Network to solve a problem which can be composed by a different number of input and output, particularly Neural Network used is a 4 Layer NN so composed (First Layer 20 Neurons - Second Layer 15 Neurons -Third Layer 10 Neurons - Fourth Layer 5 Neurons ).I need to know Neural Network weight. Here it's the problem, when i have a small number of input and output,i use the _getwb_ command which allows me to calculate NN weight and bias. Otherwise when input and output number grows up getwb command give me as result this message: '0×1 empty double column vector'. How can i get weight when numeber of input and output (and so number of weight) grows up ?? I apologize for my English which is not perfect.

Respuesta aceptada

Brendan Hamm
Brendan Hamm el 6 de Abr. de 2018
I'm not sure why you would get a 0x1 empty double column vector. You may need to post some code to help figure this piece out.
You can also try simply indexing the weights from the network:
IW = net.IW; % Cell containing the Input Weights
b1 = net.b; % Cell containing the biases
LW = net.LW; % Cell containing the layer weights
Note, many elements of the cell will likely be empty (excepting the bias weights), but you will have matrices of the weights in the non-empty cells.

Más respuestas (1)

massimiliano de martino
massimiliano de martino el 10 de Abr. de 2018
Thanks for the Answer. I post some code and information to better explain the problem. As input to NN I have done:
-Input Test = input_test{1,1} dimension 4950x1
-OutputTest = output_test{1,1} dimension 4950x1
For each value as input_test, output_test has to give me zero or one, according to input value. As NN I've used feedforwardnet. If i try to type follow command :
-IW = BETAnet1.IW = 1X1 cell array {0x0 double}
-b1 = BETAnet1.b = 1X1 cell array {0x0 double}
-LW = BETAnet1.LW = 1X1 cell array {0x0 double}
-weights = getwb(BETAnet1) = 0x1 empty double column vector
So I am not able to get information about weight value calculated during Training phase by computer. The same configuration and command has been used when i have smaller input dimension, and in this case with mentioned above command I obtain weight value. I'd want to know if the not being able to obtain weight value can be caused by excessive input and output dimension, and how can i solve this problem. Thanks for yout help
  2 comentarios
massimiliano de martino
massimiliano de martino el 11 de Abr. de 2018
I've solved this problem,but now I have another question to submit.
With command getwb I've the possibility to get weight and bias in a vector; what I can try to realize is to create a new NN (BETAnet2 in the code) with some first NN configuration layer, with only a weight value which is different(i've set 1 as test value),and i'm tring to do this with setwb command (which,if i've correct understood, means that I've changed one weight value). In particular i've tried to this with following code (input vector si a vector name dist which has as value dist beetwen two points while x_tsp is a vector of one or zero):
clear
clc
close all
load('Config==1');
Vector_Layer = [20 15 10 5];
BETAnet1=feedforwardnet([Vector_Layer]);
[BETAnet1,tr]=train(BETAnet1,dist,x_tsp);
weights = getwb(BETAnet1);
weights(100,1) = 1; % Element which i want to random change
BETAnet2=feedforwardnet([Vector_Layer]);
BETAnet2 = setwb(BETAnet2,weights);
Output_test = BETAnet2(dist);
When i try to execute this code i've the following error:
How can i salve this problem and so how can I customize weight value in a NN?
KAE
KAE el 9 de Oct. de 2018
Ask this as a new question, since you have already accepted the answer.

Iniciar sesión para comentar.

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by