Why am I getting invalid function error for a function in an installed package?

I have gone through many answers to similar problems on MATLAB answers. So, I uninstalled the deep learning toolbox and deep learning toolbox for googlenet, and reinstalled them. But, one of the function "findLayersToReplace" is giving me the above error. The .m file for the function exists in the following directory C:\..\MATLAB\Examples\nnet\findLayersToReplace.m. Here is how I am trying to call the function in my code.
[Lernablelayers, classLayer] = findLayersToReplace(neuralnetlayers);
I tried running the command "restoredefaultpath". It made other toolboxes, which were working before, to stop working. Then, I saved a copy of "findLayersToReplace.m" in the same directory where I saved my code. I can see all the desired toolboxes when I run the command "ver". But, the function is not working. Can anyone please tell me what is the proper way to implement this function? I would really appreciate the help.

3 Comments

When you are cd'd to the directory that has your code, what shows up for
which -all findLayersToReplace
Also, when you run your code and encounter the problem, please check to be sure you are still cd'd to the directory where your code is.
This is what I got:
>> which -all findLayersToReplace
'findLayersToReplace' not found.
To confirm, even though you are cd'd to the directory that you copied findLayersToReplace.m into, which says that it cannot find it? As in
ls findLayersToReplace.m
says it is in your current directory, but which says it doesn't know it? And to confirm, the directory you are working in is one of your own directories, not something underneath where MATLAB is installed?

Sign in to comment.

Answers (1)

Hi,
MATLAB examples have supporting files that are off the path and stored in the Examples directory. To run any MATLAB example with supporting functions, you must open the example in MATLAB. You can do this by clicking the 'Open Example' or 'Open Live Script' or 'Try it in MATLAB' blue buttom in the top right corner of the example in the doc. In this case, this is the example:
MATLAB then copies all the supporting files to the example folder and opens the example. You can then run the example

5 Comments

Hi Johannes,
I am not trying to run any example although I utilized the idea from this example while building my code. I am trying to use that particular function in my code which is dealing with my images that I have created from experiements. Because, I need to run the code manytimes, I find it convenient to replace layers of existing neural networks using findLayersToReplace command other than creating the function within my script. Is it not possible to use that command for any code?
Ah, I see. Then, as long as the function is on the path or in your working directory, it should work.
Although, the function was written to work with that specific example, so if you use it for other tasks it might not be garantueed to do exactly what you want.
I solved the issue by creating a function similar to findLayersToReplace on the same script as my own code. It worked! Thanks for your answers.
@Idban Alam i am facing the same prblem...how did u get rid of it?plz help
hello, i didnt even find findLayersToReplace.m。where should i go

Sign in to comment.

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Asked:

on 14 Nov 2018

Commented:

on 19 Feb 2020

Community Treasure Hunt

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

Start Hunting!