How can I use "Epoch" as a variable?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
one option in the ADAM-Training options is to use
'OutputFcn', 'Epoch' ...
right?
Matlab won't recognize 'OutputFcn' as a option in my code....
I mainly need the "Epoch" as a variable, so I can use it as a input variable in one of my layers.
What is the name of the variable "Epoch" within the "trainNetwork" function?
댓글 수: 2
Image Analyst
2022년 11월 9일
Eli, that was rude of you to erase all your posts. There's a chance that no one will answer you any more because of that.
채택된 답변
Walter Roberson
2022년 9월 26일
OutputFcn is defined as requiring a function handle or cell array of function handles.
For backwards compatibility, the name of a function might possibly be permitted, but in that case the function name would be searched within the base workspace, so it would need to refer to a "top-level" function -- either a built-in function or else a function that has a .m file named after it. For example if Epoch.m existed then possibly 'Epoch' might be accepted. But considering that ADAM is relatively recent, they might possibly not have bothered to program in support for function names (which have been discouraged in such contexts for over 20 years.) We recommend against using the names of functions.
If Epoch is the name of a variable that is storing a function handle, then use it without quotes, like 'OutputFcn', Epoch
If Epoch is the name of a function, then use @ with it, like 'OutputFcn', @Epoch
I mainly need the "Epoch" as a variable
OutputFcn does not support naming variables to be output, it only supports functions.
You could use 'OutputFcn', @(info)info.Epoch ... but the result is that the code will stop running on the first epoch:
To stop training early, make your output function return 1 (true). If any output function returns 1 (true), then training finishes and trainNetwork returns the latest network
(The reference to "true" tends to imply that really it tests for non-zero to terminate.)
so I can use it as a input variable in one of my layers.
OutputFcn does not permit you to import a computed value into a layer. OutputFcn just runs, and is expected to display something to the user, or plot something, or save a file or append to a shared (or global) variable; the only thing returned by an OutputFcn is whether to stop execution or not.
댓글 수: 5
Walter Roberson
2022년 9월 30일
If you try
options = trainingOptions("adam", 'OutputFcn', @fprintf)
then is that rejected by your MATLAB version ?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!