Unable to save trainingstats in MATLAB 2024a
I am runnning a training script based on a simulink environment. At the end when I try to save the training results, it always throws an error. I am wondering if it has something to do with the .mat format. This issue does not occur in Matlab 2023a.
%% Train the agent
trainingStats = train(agent, env, trainOpts);
%% Save Agent
results_dir = strcat(‘./Results/’,num2str(time(1)),’0′,num2str(time(2)),num2str(time(3)));
mkdir(results_dir)
save(strcat(results_dir,’/TrainingStats.mat’),"trainingStats")
generatePolicyBlock(agent)
save_system(‘untitled’,’Agent’)
%% Simulate
%addpath(‘D:MastersHiWiTikz’)
simEpisodes = 1;
simOpts = rlSimulationOptions("MaxSteps",1250,…
"NumSimulations", simEpisodes);
experience = sim(env,agent,simOpts);
save(strcat(results_dir,’/Experience.mat’),"experience")
The error message is usually:
>> load(‘C:Usersvasu3DocumentsWorksharma_ma_rlonh2dfacados_implementationrlsavedAgentsPPO20240814Agent5852.mat’, ‘savedAgentResult’)
Error using load
Cannot read file
C:Usersvasu3DocumentsWorksharma_ma_rlonh2dfacados_implementationrlsavedAgentsPPO20240814Agent5852.mat.
Warning: Directory already exists.
Error using save
Unable to save file
‘C:Usersvasu3DocumentsWorksharma_ma_rlonh2dfacados_implementationrlResults20240814TrainingStats.mat’.
The file could not be closed, and might now be corrupt.
Error in run_H2DFRL_GRU (line 195)
save(strcat(results_dir,’/TrainingStats.mat’),"trainingStats")
Warning: Unable to read some of the variables due to unknown MAT-file error.
> In matfinfo (line 9)
In finfo>fetchDescriptions (line 278)
In finfo (line 82)
In uiimport/gatherFilePreviewData (line 419)
In uiimport (line 260)
Error using load
Unable to read file
‘C:Usersvasu3DocumentsWorksharma_ma_rlonh2dfacados_implementationrlResults20240814TrainingStats.mat’. Input must be a
MAT-file or an ASCII file containing numeric data with same number of columns in each row.
Error in uiimport/runImportdata (line 470)
datastruct = load(‘-ascii’, fileAbsolutePath);
Error in uiimport/gatherFilePreviewData (line 438)
[datastruct, textDelimiter, headerLines]= runImportdata(fileAbsolutePath, type);
Error in uiimport (line 260)
gatherFilePreviewData(fileAbsolutePath);
Could someone please help outI am runnning a training script based on a simulink environment. At the end when I try to save the training results, it always throws an error. I am wondering if it has something to do with the .mat format. This issue does not occur in Matlab 2023a.
%% Train the agent
trainingStats = train(agent, env, trainOpts);
%% Save Agent
results_dir = strcat(‘./Results/’,num2str(time(1)),’0′,num2str(time(2)),num2str(time(3)));
mkdir(results_dir)
save(strcat(results_dir,’/TrainingStats.mat’),"trainingStats")
generatePolicyBlock(agent)
save_system(‘untitled’,’Agent’)
%% Simulate
%addpath(‘D:MastersHiWiTikz’)
simEpisodes = 1;
simOpts = rlSimulationOptions("MaxSteps",1250,…
"NumSimulations", simEpisodes);
experience = sim(env,agent,simOpts);
save(strcat(results_dir,’/Experience.mat’),"experience")
The error message is usually:
>> load(‘C:Usersvasu3DocumentsWorksharma_ma_rlonh2dfacados_implementationrlsavedAgentsPPO20240814Agent5852.mat’, ‘savedAgentResult’)
Error using load
Cannot read file
C:Usersvasu3DocumentsWorksharma_ma_rlonh2dfacados_implementationrlsavedAgentsPPO20240814Agent5852.mat.
Warning: Directory already exists.
Error using save
Unable to save file
‘C:Usersvasu3DocumentsWorksharma_ma_rlonh2dfacados_implementationrlResults20240814TrainingStats.mat’.
The file could not be closed, and might now be corrupt.
Error in run_H2DFRL_GRU (line 195)
save(strcat(results_dir,’/TrainingStats.mat’),"trainingStats")
Warning: Unable to read some of the variables due to unknown MAT-file error.
> In matfinfo (line 9)
In finfo>fetchDescriptions (line 278)
In finfo (line 82)
In uiimport/gatherFilePreviewData (line 419)
In uiimport (line 260)
Error using load
Unable to read file
‘C:Usersvasu3DocumentsWorksharma_ma_rlonh2dfacados_implementationrlResults20240814TrainingStats.mat’. Input must be a
MAT-file or an ASCII file containing numeric data with same number of columns in each row.
Error in uiimport/runImportdata (line 470)
datastruct = load(‘-ascii’, fileAbsolutePath);
Error in uiimport/gatherFilePreviewData (line 438)
[datastruct, textDelimiter, headerLines]= runImportdata(fileAbsolutePath, type);
Error in uiimport (line 260)
gatherFilePreviewData(fileAbsolutePath);
Could someone please help out I am runnning a training script based on a simulink environment. At the end when I try to save the training results, it always throws an error. I am wondering if it has something to do with the .mat format. This issue does not occur in Matlab 2023a.
%% Train the agent
trainingStats = train(agent, env, trainOpts);
%% Save Agent
results_dir = strcat(‘./Results/’,num2str(time(1)),’0′,num2str(time(2)),num2str(time(3)));
mkdir(results_dir)
save(strcat(results_dir,’/TrainingStats.mat’),"trainingStats")
generatePolicyBlock(agent)
save_system(‘untitled’,’Agent’)
%% Simulate
%addpath(‘D:MastersHiWiTikz’)
simEpisodes = 1;
simOpts = rlSimulationOptions("MaxSteps",1250,…
"NumSimulations", simEpisodes);
experience = sim(env,agent,simOpts);
save(strcat(results_dir,’/Experience.mat’),"experience")
The error message is usually:
>> load(‘C:Usersvasu3DocumentsWorksharma_ma_rlonh2dfacados_implementationrlsavedAgentsPPO20240814Agent5852.mat’, ‘savedAgentResult’)
Error using load
Cannot read file
C:Usersvasu3DocumentsWorksharma_ma_rlonh2dfacados_implementationrlsavedAgentsPPO20240814Agent5852.mat.
Warning: Directory already exists.
Error using save
Unable to save file
‘C:Usersvasu3DocumentsWorksharma_ma_rlonh2dfacados_implementationrlResults20240814TrainingStats.mat’.
The file could not be closed, and might now be corrupt.
Error in run_H2DFRL_GRU (line 195)
save(strcat(results_dir,’/TrainingStats.mat’),"trainingStats")
Warning: Unable to read some of the variables due to unknown MAT-file error.
> In matfinfo (line 9)
In finfo>fetchDescriptions (line 278)
In finfo (line 82)
In uiimport/gatherFilePreviewData (line 419)
In uiimport (line 260)
Error using load
Unable to read file
‘C:Usersvasu3DocumentsWorksharma_ma_rlonh2dfacados_implementationrlResults20240814TrainingStats.mat’. Input must be a
MAT-file or an ASCII file containing numeric data with same number of columns in each row.
Error in uiimport/runImportdata (line 470)
datastruct = load(‘-ascii’, fileAbsolutePath);
Error in uiimport/gatherFilePreviewData (line 438)
[datastruct, textDelimiter, headerLines]= runImportdata(fileAbsolutePath, type);
Error in uiimport (line 260)
gatherFilePreviewData(fileAbsolutePath);
Could someone please help out reinforcement learning., deep learning, machine learning, bug, matlab MATLAB Answers — New Questions