functions inside nnperformance/+sse do not print
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I was trying to see the changes of variables used in backprop.m inside nnet/nnperformace/+sse directory by deleting the semicolon after "dy = -2 .* e;" as below:
function dy = backprop(t,y,e,param)
%SSE.BACKPROP Backpropagate derivatives of performance
dy = -2 .* e
However, with my test code for 4 data points (logical OR operation example), MATLAB did not print "dy".
My test code was as below:
X = [0 0 1 1; 0 1 0 1];
y = [0 1 1 1];
net = network(1, 1, [1],[1],[0],[1]);
net.layers{1}.size = 1;
net = configure(net, X, y);
net = setwb(net, rand(size(getwb(net))));
net.trainFcn = 'trainscg';
net.layers{1}.transferFcn = 'logsig';
net.performFcn = 'sse'; % sum squared error
net.trainParam.showWindow=0;
net.trainParam.showCommandLine=1;
net = configure(net, X, y);
net = train(net,X,y);
y_pred = net(X)
Is there any reason for this happening in MATLAB? Is a binary code running instead to speed up the operation?
I also found that I could not print any variables from the functions inside +sse directory.
I want to see how these variables change during training in each iteration.
Is there any way to print these variables?
댓글 수: 0
채택된 답변
Angelo Yeo
2024년 12월 7일
Like @Githin George said, use breakpoints to debug the code if you want to see how things work behind the scene.
And, when getting deeper and deeper with breakpoints, I think it's so true that it uses a binarized function under the hood when calculating gradients. In my personal opinion, it should have something to do with speeding up.
However, it looks like there are points of time where parameters are updated in the trainFcn (trainscg in your case).
댓글 수: 0
추가 답변 (2개)
Githin George
2024년 12월 6일
이동: Angelo Yeo
2024년 12월 6일
I've tried adding a breakpoint into the function mentioned "sse.backprop" and I could observe that the breakpoint is never hit. So i assume that your test code is never calling the function "sse.backprop".
I would also like to add a word of caution not to edit the toolbox functionality since it may lead to unexpected behaviours. In my case, I was able to observe this dialog mentioning that edit access is denied.
I hope this answers your query.
댓글 수: 0
Walter Roberson
2024년 12월 6일
After changing code inside the MATLAB directories, you need to
rehash toolboxcache
Is a binary code running instead to speed up the operation?
Sort of, but not exactly.
What is happening is that for user-provided files, the first time that a function is used in a session, the function file is parsed and a tokenized tree structure is created for it (and possibly parts of it are partially compiled.) This version of the file is cached. If the user-provided .m file is altered without MATLAB noticing, the preparsed file version of it will continue to be used... omitting the changes to the file. MATLAB tends to notice changes to user-provided files "soon", and automatically re-parses files, but there are some circumstances (such as function handles) where the cached version continues to be used.
For Mathworks supplied files, there is a pre-built cache of exactly the same nature. Except that Mathworks does not monitor the directories that Mathworks-supplied files live in, and so will never spontaneously notice changes to the files. Once the cache of Mathworks supplied files is built, the pre-parsed versions live on, until the user specifically requests that the toolbox cache be rebuilt.
So, after changing a Mathworks-supplied files, you need to specifically ask for the cache to be rebuilt.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!