How can I use "Epoch" as a variable?

2 Ansichten (letzte 30 Tage)
Eli
Eli am 26 Sep. 2022
Kommentiert: Rena Berman am 15 Nov. 2022
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 Kommentare
Image Analyst
Image Analyst am 9 Nov. 2022
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 am 15 Nov. 2022
(Answers Dev) Restored edit

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 26 Sep. 2022
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 Kommentare
Walter Roberson
Walter Roberson am 28 Sep. 2022
Please remind us which MATLAB version are you using.
Walter Roberson
Walter Roberson am 30 Sep. 2022
If you try
options = trainingOptions("adam", 'OutputFcn', @fprintf)
then is that rejected by your MATLAB version ?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by