Error message "'sequenceInputLayer requires Deep Learning Toolbox" running MATLAB from terminal
5 views (last 30 days)
Show older comments
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.
0 Comments
Answers (2)
Umar
on 5 Jul 2024
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 Comments
Umar
on 7 Jul 2024
Edited: Walter Roberson
on 7 Jul 2024
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.
Umar
on 8 Jul 2024
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.
0 Comments
See Also
Categories
Find more on Sequence and Numeric Feature Data Workflows 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!