I am working on a LSTM model and trying to use a DataLoader to provide the data. I am using stock price data and my dataset consists of:
- Date (string)
- Closing Price (float)
- Price Change (float)
Right now I am just looking for a good example of LSTM using similar data so I can configure my DataSet and DataLoader correctly.
To test my DataLoader
I have the following code:
for i, d in enumerate(dataloader):
print(i, d)
Using the following definition of dataloader
the test works.
dataloader = DataLoader(pricedata,
batch_size=30,
shuffle=False,
num_workers=4)
This give me x batches of size 30, which makes sense.
However, I need to use a sliding window of size n so, assuming there are k instances in the dataset, I would like k-n batches with n instance in each batch.
So I redefined dataloader
as:
dataloader = DataLoader(pricedata,
batch_sampler=torch.utils.data.sampler.SequentialSampler(pricedata),
shuffle=False,
num_workers=4)
With this change I get the following error message:
TypeError: 'int' object is not iterable
when the code hits the test:
for i, d in enumerate(dataloader):
Based on this I have two questions:
- Is
torch.utils.data.sampler.SequentialSampler
the appropriate sampler to use for a sliding window? - Can anyone point me to a good example of configuring an LSTM using a
DataLoader
to load numeric data? All the examples I have seen are for NLP.
Thanks