Dealing with Large training datasets saved in a number of .mat files

5 vues (au cours des 30 derniers jours)
Ruohao Zhang
Ruohao Zhang le 10 Août 2020
Commenté : Ruohao Zhang le 21 Août 2020
Hello all,
I have run into a problem where I need to train a LSTM signal classifier with huge amount of data.
Each 1D signal is around 100k samples, every 48 signals are saved in a .mat file. The total number of .mat files is around 2000.
The labels are similarly saved in corresponding .mat files in a different folder.
I would like to know if there's a way to train the network without the necessity of loading the whole thing into memory. (with 64GB ram I can only load ~1300files at once)
Your help will be very much appreciated.

Réponse acceptée

Divya Gaddipati
Divya Gaddipati le 13 Août 2020
You can use fileDatastore for this purpose.
trainData = fileDatastore('/path/to/data', 'ReadFcn', @load, 'FileExtensions', '.mat');
You can either use "load" or your own custom function defining how to load the data.
You can also refer to this link for more information on training LSTM while loading data using fileDatastore.
  1 commentaire
Ruohao Zhang
Ruohao Zhang le 18 Août 2020
Thank you for this answer, what I ended up doing is to decompose all the files that I currently have into smaller files each containing only one matrix and create a datastore from there. The problem I encountered is the loading function is acting weird when you call it in filedatastore. when I load the .mat in the command it returns as a matrix where when it is loaded in by calling filedatastore and combine, it loaded as a 1x1 cell. So I have to write my own load func to make sure the correct format

Connectez-vous pour commenter.

Plus de réponses (1)

Frantz Bouchereau
Frantz Bouchereau le 20 Août 2020
Modifié(e) : Frantz Bouchereau le 20 Août 2020
Ruohao,
You can use two signalDatastores - one to read your signal files and another one to read your labels. You can then combine them using combine(), split the combinedDatastore into training and test sets using subset() and then feeding the combined datastores into the training function of the LSTM network.
With signslDatastore you do not need to write a load function. You specify the variable names you want read from the mat file and those are returned at every read.
HTH
  1 commentaire
Ruohao Zhang
Ruohao Zhang le 21 Août 2020
Thank you for your reply. Indeed, signaldatastores can be really helpful, but sadly this function is only introduced in 2020a where I am still using 2019b. It can be a good motivation to update my software now:)

Connectez-vous pour commenter.

Catégories

En savoir plus sur AI for Signals dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by