How to manually change pre-trained CNN's (AlexNet) weights?

조회 수: 2 (최근 30일)
Yuan Du
Yuan Du 2017년 8월 10일
답변: Dianxin 2021년 3월 29일
To whom can help:
I am using MATLAB r2017a. I am trying to change the weights of a pre-trained CNN, like alexnet, using the following codes. Unfortunately, I got the following errors. Are there any suggestions to by-pass this read-only constrain?
Thanks a lot! Jason
" You cannot set the read-only property 'Layers' of SeriesNetwork"
% code
>> net=alexnet
>> net.Layers(2,1).Weights=net.Layers(2,1).Weights*10;

답변 (3개)

J
J 2018년 4월 16일
Bump! I have a hard time believing that one cannot take an existing SeriesNetwork, and either:
1. Modify properties of it, or...
2. ... create a new SeriesNetwork that is a copy of the existing one, but has different values for certain properties
Also, I would image there is a way to take an existing SeriesNetwork, then addLayers/removeLayers/connectLayers and convert back to a SeriesNetwork, rather than being stuck with the DAGNetwork that is generated (if it really is naturally represented as SeriesNetwork)? Or if not, that there is some workaround?
I mean, it makes NO SENSE that if, for example, I have a SeriesNetwork with a dropoutLayer at default 0.5 that I can't just modify that to 0.25 or 0.6 or whatever I want and then re-train without having to convert to a DAGNetwork and then be stuck with a DAGNetwork (certain functions will only operate on SeriesNetwork--take for example, deepDreamImage).

mizuki
mizuki 2017년 8월 13일
In R2017a, the only supported way to create a SeriesNetwork is to use trainNetwork, and it is not possible to modify it.
  댓글 수: 1
Tom Hope
Tom Hope 2018년 1월 10일
OK - that seems a pretty strict limitation. What about 2017b?

댓글을 달려면 로그인하십시오.


Dianxin
Dianxin 2021년 3월 29일
You can convert the DAG net to an object and then change that object with is a structure, then load that back. It is a possible way.

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by