backwardTape used in MATLAB2021a

5 views (last 30 days)
Yimin
Yimin on 12 Apr 2024
Commented: Walter Roberson on 13 Feb 2025 at 3:40
I need to make some modification in built-in function when called backwardTape"
grad = backwardTape(tm,{y},{initialAdjoint},x,retainData,false,0);"
at MATLAB2021a. However, I could see the nested function when called
grad = backwardTape(tm,{y},{initialAdjoint},x,retainData,false,0)
But where is the backwardTape function? As I am running MATLAB in a cluster so I don't have authority to overwrite the built-in function called by backwardTape so I need to save some functions in my drive that I could overwrite functions.

Answers (1)

AKennedy
AKennedy on 13 Feb 2025 at 3:18
In MATLAB, built-in functions like backwardTape are typically part of the proprietary codebase and are not directly accessible or modifiable by users. However, you can work around this limitation by creating a wrapper function or script that calls backwardTape and then processes its outputs according to your needs.
  • Create a Wrapper Function:
function grad = myBackwardTapeWrapper(tm, y, initialAdjoint, x, retainData)
% Call the original function
grad = backwardTape(tm, {y}, {initialAdjoint}, x, retainData, false, 0);
% Modify grad as needed
% grad = yourModificationFunction(grad);
end
  • Use the Wrapper: Save this function in your MATLAB path or specify its location when calling it.
  • Ensure the wrapper is accessible on the cluster.
  1 Comment
Walter Roberson
Walter Roberson on 13 Feb 2025 at 3:40
backwardTape is defined in deep.internal.recording.operations.DlconvBackwardOp as a method of deep.internal.recording.TapeManager . I am not sure that calling it through a wrapper is even possible.
In any case you would have to copy @dlarray and modify the copy in order to call the wrapper instead of the direct function.

Sign in to comment.

Categories

Find more on Parallel and Cloud in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!