How can I use "Epoch" as a variable?

1 回表示 (過去 30 日間)
Eli
Eli 2022 年 9 月 26 日
コメント済み: Rena Berman 2022 年 11 月 15 日
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
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.
Rena Berman
Rena Berman 2022 年 11 月 15 日
(Answers Dev) Restored edit

サインインしてコメントする。

採用された回答

Walter Roberson
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
Walter Roberson 2022 年 9 月 28 日
Please remind us which MATLAB version are you using.
Walter Roberson
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 ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by