Is it possible to initialize a conv2D layer with custom weights (from other layer for ex) ?

조회 수: 1 (최근 30일)
I need to use weights from a different network conv layer to initialize another conv layer, the closest thing I could find was the custom initialization function but I'm still unsure if that is possible to do or not. Would the data returned by the training function be useable for something like this?
One more question, is there a way to access individual channels within a conv2d layer, I can set paramters for the whole layer, is it possible to do so for specefic channels, like set the learning factor to zero for one specefic filter?

답변 (1개)

Srivardhan Gadila
Srivardhan Gadila 2019년 8월 6일
편집: Srivardhan Gadila 2019년 8월 7일
Using weights of different network to the current network:
for 2 networks net1 & net2, copy the layers to some variable
layers = net1.Layers;
layers(net1layerindex).Weights(net1index) = net2.Layers(net2layerindex).Weights(net2index);
Let's say you want to set weights of a channel of a layer of a CNN to zeros(channelDimension)
layers(convLayerIndex).Weights(:,:,channelIndex) = zeros(channelDimension)
%also
layers(convLayerIndex).Weights(:,:,channelIndex,Index) = zeros(respectiveDimension)
Use the above layers to create a DAG or a Series network. You can also refer to the documentation of the assembleNetwork function which helps creating deep learning networks from layers without training.
I think setting the Learning factor for a specific filter is not possible but you can set it for the whole layer as follows:
layer.WeightLearnRateFactor = 0;
  댓글 수: 3
Alla
Alla 2019년 8월 7일
편집: Alla 2019년 8월 7일
Thank you for the clarification, I actually did this as a way around the read-only problem, but when I get to the end, having a new set of layers initialized by the weights I need with specefic layers frozen, when I get there I still run into the problem of assembling a DAG netowrk since I need both a graph and a Connections file, and when I try to use the connections properties of my original DAG netowork I run into the same read-only problem. I can assemble a graph from the layers using the function layergraph but that one generates a Connections property that is not right (generates a series connection).
I even tried to manually change the connections but again they're read-only, it's starting to seem like these changes are not possible which is a shame,same for accessing individual channels, these changes would open the door for more under the hood tweaking that is necessary for research.

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

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by