How can I modify the weights of a pre-trained Alexnet in 2018a?

3 ビュー (過去 30 日間)
Valerio Gloria
Valerio Gloria 2018 年 6 月 22 日
回答済み: Mingrun Wang 2018 年 6 月 22 日
Hi everybody. For a research project I need to modify the weights of a pre-trained Alexnet. When I try to do so:
net = alexnet;
net.Layers(2).Weights = net.Layers(2).Weights * 0.01;
Matlab 2017b answers me that they are read-only values. Since it looks a very strong limitation, does anybody know if in version 2018a they solved that problem? Or maybe someone has solve it with a script?
Thanks.

回答 (1 件)

Mingrun Wang
Mingrun Wang 2018 年 6 月 22 日
layers=net.Layers; layers(2).Weights=layers(2).Weights * 0.01; And i also provide you the following ways to make up for the conversion between external layer and internal layer.(external layer is the wrapper for internal layer) externalLayer→internalLayer: nnet.cnn.layer.Layer.getInternalLayers( externalLayers ) %this function will return an internal instance(copy).
internalLayer→externalLayer:externalLayersConstructor(e.gnnet.cnn.layer.FullyConnectedLayer(internalLayer));
create an internal layer(e.g nnet.internal.cnn.layer.FullyConnected(name,inputsize,outputsize));

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by