Azzera filtri
Azzera filtri

Error message "'sequenceInputLayer requires Deep Learning Toolbox" running MATLAB from terminal

102 visualizzazioni (ultimi 30 giorni)
I am training an LSTM network (script called lstm_classification.m) on some time series data (MATLAB R2024a). Training uses the Deep Learning toolbox which is installed correctly. When I run the script from the GUI everything works fine, but when I call the script from R, I get the following error message:
sequenceInputLayer requires Deep Learning Toolbox.
Error in lstm_classification (line 463) sequenceInputLayer(inputSize)
Error in run (line 112)
evalin('caller', strcat(script, ';'));
Calling the script from R used to work without issues. This error message occured only recently. This is my script lstm_classification.m around line 463 (sequenceInputLayer...):
...
%% Define LSTM Network Architecture
inputSize=nofeatures;
% numHiddenUnits=100;
numHiddenUnits=hiddenunits;
% numClasses=9;
numClasses=notreatments_afterdrop;
layers=[ ...
sequenceInputLayer(inputSize)
bilstmLayer(numHiddenUnits,'OutputMode','last')
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer
];
...
What is the matter here? Is the toolbox now not accesible without the MATLAB-GUI running? It used to work perfectly. Any help is greatly appreciated. Thanks.

Risposte (2)

Umar
Umar il 5 Lug 2024 alle 12:22
Hi Richard,
Can you ensure that the Deep Learning Toolbox is properly loaded and accessible when running the script from R. You can explicitly add the toolbox path or initialize it within the script to make the required functions available.
  5 Commenti
Umar
Umar il 7 Lug 2024 alle 18:19
Modificato: Walter Roberson il 7 Lug 2024 alle 20:04
Hi Richard,
You are right about complications. The issue you are facing with the Deep Learning Toolbox not being recognized by Matlab despite being installed is a common problem that can occur due to various reasons. One potential solution is to manually add the toolbox folder to the Matlab path using the addpath function. Here's a step-by-step guide on how to resolve this issue:
1. Locate the installation folder of the Deep Learning Toolbox on your system.
2. Copy the path to the toolbox folder.
3. In your Matlab script, use the addpath function to add the toolbox folder to the Matlab path. For example:
toolboxPath = '/path/to/Deep Learning Toolbox';
addpath(toolboxPath);
By adding the toolbox folder to the Matlab path, you are ensuring that Matlab can locate and access the functions and resources of the Deep Learning Toolbox. This should resolve the issue of the ".Location" property not working and allow you to initialize and use the toolbox within your script successfully.
If you encounter any further difficulties or if this solution does not work, please provide additional details or error messages to further assist you in troubleshooting the problem.
Richard Ottermanns
Richard Ottermanns il 8 Lug 2024 alle 8:28
Thanks, unfortunetely step 1 seems to be impossible. I have 34 subfolders in "/usr/local/MATLAB/R2024a/toolbox". None of them are called "deeplearningtoolbox" or alike. Neveretheless the toolbox must be somewhere because my script works perfectly when I run it from the GUI instead of the command line. So, I simply added every subfolder in "...toolbox" to my script as you advised in steps 2+3. Like this:
toolboxPath = '/usr/local/MATLAB/R2024a/toolbox/bioinfo';
addpath(toolboxPath);
But the error remains the same if I run my script from the command line. The error message is:
sequenceInputLayer requires Deep Learning
Toolbox.
Error in lstm_classification (line 538)
sequenceInputLayer(inputSize)
Error in run (line 112)
evalin('caller', strcat(scriptStem, ';'));
So, maybe there is something else going on? I assumd that the toolbox must be available if I add every folder in ".../toolbox" to the path.

Accedi per commentare.


Umar
Umar il 8 Lug 2024 alle 15:34
Hi Richard,
Sorry to hear that you’re are still having problems. When encountering issues with the availability of the Deep Learning Toolbox in MATLAB scripts, there are several steps to consider for troubleshooting.
Firstly, ensure that the Deep Learning Toolbox is correctly installed in your MATLAB environment. You can check this by running the following command in the MATLAB command window:
ver
Look for the Deep Learning Toolbox in the list of installed toolboxes. If it is not listed, you may need to install it through the MATLAB Add-Ons menu.
Even though you have added the toolbox subfolders to the script's path using addpath, there might be a discrepancy in the search path when running the script from the command line. To verify the MATLAB search path, you can use the following command:
path
Ensure that the toolbox directories are included in the search path displayed.
Sometimes, running MATLAB scripts from the command line may not inherit all environment variables set in the GUI environment. Check if there are any specific environment variables related to MATLAB or the Deep Learning Toolbox that need to be set for command-line execution.
Instead of relying on relative paths, consider using the full path specification to the Deep Learning Toolbox functions in your script. This ensures that the script explicitly knows where to find the required functions. For example:
toolboxPath = '/usr/local/MATLAB/R2024a/toolbox/deeplearning'; addpath(toolboxPath);
Ensure that the script initializes the Deep Learning Toolbox properly before calling functions from it. You can add the following line at the beginning of your script to explicitly initialize the Deep Learning Toolbox:
deepLearningSetup(); % Custom function to initialize the Deep Learning Toolbox
Hopefully, by following these steps, you can troubleshoot the availability of the Deep Learning Toolbox in your MATLAB script when running it from the command line. Remember to check the toolbox installation, search path, environment variables, path specifications, and script initialization to ensure smooth execution.

Categorie

Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Prodotti


Release

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by