How to retain the derivative trace of a dlarray out of dlfeval function

조회 수: 2 (최근 30일)
Xiaowen Jiang
Xiaowen Jiang 2021년 7월 18일
답변: Akshat 2024년 2월 16일
Hi! In the deep learning toolbox, when we set 'RetainData' to be true in dlgradient function, a dlarray retains the derivative trace until the end of the dlfeval function call that evaluates the dlgradient. If we want to reuse this trace again outside the function, for example, to compute higher order derivatives but not in the original function which is used to compute gradient, how can we do that? Thank you very much for you help.

답변 (1개)

Akshat
Akshat 2024년 2월 16일
Hi Xiaowen,
As you asked in the question, you want to retain the trace in order to perform some tasks like computing higher order derivatives.
If you go through https://www.mathworks.com/help/deeplearning/ref/dlarray.dlgradient.html#mw_ef6d7d9f-bce7-4417-ade7-fa36594d55bb, it is written that if you set the flag "EnableHigherDerivatives" as true, you can retain the intermediate values for future calls of the "dlgradient" function.
An example given for this is https://www.mathworks.com/help/deeplearning/ug/trainwasserstein-gan-with-gradient-penalty-wgan-gp.html, you can refer to the documentation page for more examples.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Custom Training Loops에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by