Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zakattacktwitter/2da0ae129f3c1c10bff5 to your computer and use it in GitHub Desktop.
Save zakattacktwitter/2da0ae129f3c1c10bff5 to your computer and use it in GitHub Desktop.
Example of using Dataset with variable sized mini-batch items.
local Dataset = require 'dataset.Dataset'
local dataset = Dataset('http://d3jod65ytittfm.cloudfront.net/dataset/mnist/train.t7')
local getBatch, numBatches = dataset.sampledBatcher({
batchSize = 20,
inputDims = { 1, 32, 32 },
verbose = true,
processor = function(res, processorOpt, input)
local y = math.random(32)
local spect = torch.randn(y, 32)
input:fill(0)
input[1]:narrow(1, 1, y):copy(spect)
return true
end,
})
local b = 1
while b <= numBatches() do
print('getting batch '..b..'...')
local batch = getBatch()
b = b + 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment