MATLAB: Edit or shadow toolbox function

built-inchangedropouteditlstmMATLABshadowtoolbox

Hey guys, I tried googling a bit but found nothing on this topic… which is weird as I suspect that this is not the first time someone is dealing with this "issue".
I am trying to implement a feature in an existing matlab function. The function is called "lstmForward.m" and is part of the Neural Network Toolbox. Specifically I would like to add variational dropout to the existing LSTM functions…
I can not get it to work however. I have already tried:
  • Shadowing the original function, which does not seem to work, even though my path is higher. Using which I can only find my own function, and not even the builtin one.
  • I have tried editing the function, which worked, but the function does not carry out my added code. It simply ignores it. Even simple things such as declaring a=1; do nothing. It simply passes over it and carries on.
The problem is that I can't just create my own function as it is pretty far down the function tree, several layers deep, and I would have to change everything on top. I also don't even think this could work…
So, do you have any ideas? Or do I have to give up on this prospect… Thanks.

Best Answer

I strongly recommend against modifying functions in MathWorks toolboxes for some of the same reasons Jan called out. If you must do so, changes to files under the matlabroot directory will not be recognized until or unless you update the toolbox path cache.
If you believe that a toolbox function has a bug that should be fixed or would like to request that it be enhanced with additional capabilities, please contact Technical Support using the Contact Us link in the upper-right corner of this page and file your bug report / enhancement request.