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?
0 个评论
回答(1 个)
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!