Sha256: f45a5bb9adca2a99fccd7f1724c41bd2eef6d14146e94d997dc3daaebd7ec123

Contents?: true

Size: 463 Bytes

Versions: 1

Compression:

Stored size: 463 Bytes

Contents

module Torch
  module Utils
    module Data
      class DataLoader
        def initialize(dataset, batch_size: 1)
          @dataset = dataset
          @batch_size = batch_size
        end

        def each
          size = @dataset.size
          start_index = 0
          while start_index < size
            yield @dataset[start_index...(start_index + @batch_size)]
            start_index += @batch_size
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
torch-rb-0.1.2 lib/torch/utils/data/data_loader.rb