How to Manually Change dlnet's Learnable Parameters?

조회 수: 3 (최근 30일)
Theron FARRELL
Theron FARRELL 2019년 11월 24일
답변: Gautam Pendse 2020년 1월 8일
Hi,
I want to add some minor noise to a dlnet.Learnables.
Firstly, I tried to convert each learnables from table to cell to a single dlarray by
yy = cell2mat(table2array(dlnet.Learnables(1, 3)));
zz = yy + normrnd(0, 0.005, size(yy));
But I found I could not manage to convert zz back and have it stored in dlnet.Learnables(1, 3).
Then, I tried to use dlupdate() function like
Noise_Adder = @(para, Noise_Sigma) para + normrnd(0, Noise_Sigma, size(para));
G_Add_Noise_Sigma = 0.005;
for l = 1:size(dlnet.Learnables, 1)
dlnet.Learnables(i, 3) = dlupdate(Noise_Adder, dlnet.Learnables(i, 3), G_Add_Noise_Sigma);
end
Yet I got an error saying
Dot indexing is not supported for variables of this
type.
Error in
deep.internal.recording.containerfeval>iProcessTable_Nout_Nin
(line 262)
varargvals{input} = varargin{input}.Value;
Error in
deep.internal.recording.containerfeval>iDispatch_Nout_Nin
(line 194)
[varargout{1:nargout}] =
iProcessTable_Nout_Nin(allowNetInput,
makeNetOutput, fun, paramFun, c, varargin{:});
Error in deep.internal.recording.containerfeval
(line 41)
[c, varargout{1:nargout-1}] =
iDispatch_Nout_Nin(allowNetInput,
makeNetOutput, fun, paramFun, c,
varargin{:});
Error in deep.internal.networkContainerFun (line
15)
[c, varargout{1:nargout-1}] =
deep.internal.recording.containerfeval(...
Error in dlupdate (line 102)
[P, varargout{1:nargout-1}] =
deep.internal.networkContainerFun(...
So how can I achieve my goal? Many thanks.
  댓글 수: 1
Theron FARRELL
Theron FARRELL 2019년 11월 25일
Actually, I managed to implement what I want manually by adding noise layer by layer
G_Para_Noise_Sigma = 0.05;
[dlnet_G.Learnables] = Add_Para_Noise(dlnet_G.Learnables, G_Para_Noise_Sigma);
function [para] = Add_Para_Noise(para, sigma)
for layer = 1:size(para, 1)
para.Value{layer} = para.Value{layer} + normrnd(0, sigma, size(para.Value{layer}));
end
end
But I know it is quite naive and inefficient. Is there any better way to do it, especially by using dlupdate?
Thanks.

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

채택된 답변

Gautam Pendse
Gautam Pendse 2020년 1월 8일
Hi Theron,
The first syntax for dlupdate may be what you are looking for:
% Update learnable parameters in dlnet by adding 1
myfun = @(x) x + 1;
dlnet = dlupdate(myfun,dlnet);
Hope this helps,
Gautam

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by