Edit or shadow toolbox function
Mostra commenti meno recenti
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.
4 Commenti
Jan
il 27 Nov 2018
I do not understand, what you try to do. Shadowing a toolbox function is a bad idea in general and you cannot expect the concerned toolbox to work properly afterwards. If you really want to do this, sharing your work with a colleague forces him to be open to destroy his or her Matlab installation.
which -all should find the shadowed function also.
You have tried to edit which function? The shadowed one or the original? Did you save the code after the changes? If the file locked by mlock? Is the a P-file or Mex function running with the same name? "It simply ignores it" might reflect your observation, but it does not allow to suggest a solution. What do you expect "a=1" to do? What "passes over it"?
What does "pretty far down the function tree" mean? On what "top" do you have to change what?
Daniel Greff
il 27 Nov 2018
Jan
il 28 Nov 2018
I still do not get it: Without Admin privileges, you can neither edit nor remove nor replace the original toolbox function. The shadowing should work using Steven's suggestion of
rehash toolboxcache
but as far as I remember the original function is still prefered, if its folder is the current directory. So care about not cd -ing into the Matlab's root folder.
I have shadowed some toolbox functions also with a great care. During the startup of Matlab I add a folder to the path depending on the Matlab version, which contains improved versions of the functions, e.g. a much faster ind2rgb and a faster C-Mex for iscellstr . I've tested this exahsutively, on different Matlab versions, OS and so on before I trusted this for productive work.
You can check if there are P- or Mex-functions with the same name by which -all as mentioned already.
Steven Lord
il 28 Nov 2018
Shadowing of a function with a function by the same name in another directory may not work in this case, as I suspect the function Daniel wants to change depends upon private functions that will only be available in the directory containing the original function.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!