Created
February 5, 2016 15:44
-
-
Save zakattacktwitter/2da0ae129f3c1c10bff5 to your computer and use it in GitHub Desktop.
Example of using Dataset with variable sized mini-batch items.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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