Datastore with overlapping read function
4 views (last 30 days)
Show older comments
I have some data stored in 20 spreadsheets. Each spreadsheet has a size of about 4000x200. I want to store the data in a datastore, and feed it into a temporal-CNN in chunks of 100 rows. However, I want the rows to overlap. For example, the first value the datastore will return is a 100x200 array, which corresponds to rows 1:101 in the spreadsheet. The second value it should return is rows 2:102, then 3:103, etc.
The only way that I can seem to do this right now is to read all the spreadsheets into a 80,000x200 array in matlab, and then create a 3D array with size 79,900x100x200, and then use a for loop to iterate through the array, copying over chunks of 100x200 from the 2d array into the 3d array. Finally, I put the 3d array into an arrayDatastore. However, this seems really inefficient, and I have to keep the batch size for the CNN pretty small to avoid errors.
I also tried saving each of the 100x200 arrays into a grayscale png, and then creating an imageDatastore with the 79,900 images. This lets me have a larger batch size, but A) it takes about 8 hours to convert all the data into images, and B) training the CNN takes about 8-10 times longer (4-5 hours instead of 30 mins).
Is there a better way to do this?
0 Comments
Answers (1)
Matt J
on 23 Apr 2022
Edited: Matt J
on 23 Apr 2022
For example, the first value the datastore will return is a 100x200 array, which corresponds to rows 1:101 in the spreadsheet. The second value it should return is rows 2:102, then 3:103, etc.
An equivalent to that would be to make the CNN fully convolutional (if it isn't already) with input size 4000x200. Then, you could feed an entire spreadsheet as input at once.
11 Comments
Matt J
on 27 Apr 2022
It seems that it is not possible to create a network without an input layer. I can make the network with an imageinputlayer of size 4000x200
You would have to turn off the normalizations that it is doing, in that case. The imageInputLayer is not a convolutional layer you can't get shift-invariant output if normalization is happening.
See Also
Categories
Find more on Deep Learning Toolbox 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!
