フィルターのクリア

how to initialize the neural network to a set of weights ???

28 ビュー (過去 30 日間)
Mariem Harmassi
Mariem Harmassi 2012 年 10 月 16 日
コメント済み: LukasJ 2020 年 11 月 6 日
I created my NN with patternet ??

採用された回答

Greg Heath
Greg Heath 2012 年 10 月 20 日
Unlike the older nets (e.g., newfit, newpr, newff,...), you cannot assign weights to the newer networks (e.g., fitnet, patternnet, feedforwardnet,...) unless the net is configured.
There are two ways to configure the net before manually assigning your own initial weights. Both will assign initial weights that you can overwrite:
1. help/doc configure.
net = configure(net, x, t );
2. Train the net for 1 epoch
net.trainParam.epochs= 1.
net = train(net,x,t);
Hope this helps.
Thank you for formally accepting my answer.
Greg
  2 件のコメント
Mariem Harmassi
Mariem Harmassi 2012 年 10 月 20 日
ok i will try to cinfigure the net before training cauz the second solution is not a good one i need to train the net according to a specifical set of weignts .
Samisam
Samisam 2018 年 1 月 7 日
@Greg Heath can I do a manual weight initialization before I train the net???
I mean if I have an optimal weight from a spesific algorithm and I want to create a NN to test data using these weights is there any way to do this without training the net again??

サインインしてコメントする。

その他の回答 (3 件)

Greg Heath
Greg Heath 2012 年 10 月 19 日
編集済み: Greg Heath 2012 年 10 月 20 日
net = patternet;
will default to H = 10 hidden nodes. For other values use
net = patternnet(H);
If
size(input) = [I N ]
size(target) = [O N ]
the node topology is I-H-O.
For a manual weight initialization, first configure the net:
net = configure(net,x,t);
For a random weight initialization, initialize the random number generator. Then generate and assign the weights:
rng(0)
IW = 0.01*randn(H,I);
b1 = 0.01*randn(H,1);
LW = 0.01*randn(O,H);
b2 = 0.01*randn(O,1);
then
net.IW{1,1} = IW;
net.b{1,1} = b1;
net.LW{2,1} = LW;
net.b{2,1} = b2;
Hope this helps.
Thank you for formally accepting my answer.
Greg
  4 件のコメント
Heather Zhang
Heather Zhang 2016 年 8 月 30 日
Thank you Greg. "configure" works really well.
LukasJ
LukasJ 2020 年 11 月 6 日
Dear Greg Heath,
unfortunately configuring the net doesn't do the trick for me:
I tried setting the inital weights manually e.g.
net.iw{1,1} = zeros(...
and via
net.initFcn = 'initlay';
net.layers{1,1}.initFcn = 'initwb';
net.layers{2,1}.initFcn = 'initwb';
net.InputWeights{1,1}.initFcn = 'midpoint';
net.LayerWeights{2,1}.initFcn = 'midpoint';
initFcn to call for midpoint initialization. The first won't update any weights after training, the former won't do anything (still random weights when I check before training, training results after fixed epochs are not comparable).
Your help would be very much appreciated!
Best regards,
Lukas

サインインしてコメントする。


renz
renz 2012 年 10 月 19 日
net.IW{1} = %input weights
net.LW{2} = %layer weights
% biases:
net.b{1} =
net.b{2} =

Sara Perez
Sara Perez 2019 年 9 月 12 日
You can specify your own function for the initialization of the weights with 'WeightsInitializer' in convolution2dLayer.
layer = convolution2dLayer(filterSize,numFilters, ...
'WeightsInitializer', @(sz) rand(sz) * 0.0001, ...
'BiasInitializer', @(sz) rand(sz) * 0.0001)
info here:

カテゴリ

Help Center および File ExchangeSequence 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