Having problem in giving .mat files as input to CNN for classification task.

조회 수: 5 (최근 30일)
I want to give .mat files each of size 27*27*100 as input to my CNN for classification task. When i am running my program, its giving following error:-
------------------------------------
Error using trainNetwork (line 150)
Unable to read file: 'D:\Matlab_Files\Convolution_Fusion_Initial\FusionFolder1\1\I1.mat'.
Error in NetworkAfterFusion2 (line 88)
netTransfer = trainNetwork(allImages,layers,options);
Caused by: Error using matlab.io.datastore.ImageDatastore/read (line 74)
Unable to read file: 'D:\Matlab_Files\Convolution_Fusion_Initial\FusionFolder1\1\I1.mat'.
Error using matlab.io.datastore.splitreader.WholeFileCustomReadSplitReader>iErrorOnReadFcn
(line 106)
Error using ReadFcn @readDatastoreImage function handle for file
D:\Matlab_Files\Convolution_Fusion_Initial\FusionFolder1\1\I1.mat.
Error using imread>get_format_info (line 543)
Unable to determine the file format.
Error in imread (line 391)
fmt_s = get_format_info(fullname);
Error in readDatastoreImage (line 12)
data = imread(filename);
----------------------------------------------------
The function trainNetwork is not able to accept the .mat format even if i am giving 'FileExtension' as '.mat' at the time of creating image datastore object.
allImages = imageDatastore('D:\Matlab_Files\Convolution_Fusion_Initial\FusionFolder1', 'IncludeSubfolders', true,'LabelSource', 'foldernames','FileExtensions','.mat');

채택된 답변

awezmm
awezmm 2018년 11월 2일
편집: awezmm 2018년 11월 2일
If I understand correctly, your mat file has the "values" of an image in matrix form. The problem is with imread. It cannot read a file with .mat extension: Heres official doc: officaldoc Look at the formats in that page
You instead need to convert the mat file into an image and then pass the image into your network. These might help: convertexample1 convertexample2
  댓글 수: 2
Stephen23
Stephen23 2018년 11월 2일
편집: Stephen23 2018년 11월 2일
@awezmm: is there a reason why you provided a link to a third-party copy of the MATLAB documentation from 2005, and not simply to the current official MATLAB documentation?
awezmm
awezmm 2018년 11월 2일
편집: awezmm 2018년 11월 2일
Because the formats were easier to see as they were close to the beginning of that page. Its harder to find the imread formats on the official function doc page, but I replaced it.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

virgile
virgile 2023년 1월 3일
Hello, I have a similar project and i don't know how to start. Could you plz post your notebook, It would really help me.

카테고리

Help CenterFile Exchange에서 Preprocess Data for Deep Neural Networks에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by