Sha256: d65c66a2ac125b94794942bcb1816a91c3829700a6750785e20c147d407960d5

Contents?: true

Size: 446 Bytes

Versions: 41

Compression:

Stored size: 446 Bytes

Contents

module Torch
  module Utils
    module Data
      class Subset < Dataset
        def initialize(dataset, indices)
          @dataset = dataset
          @indices = indices
        end

        def [](idx)
          @dataset[@indices[idx]]
        end

        def length
          @indices.length
        end
        alias_method :size, :length

        def to_a
          @indices.map { |i| @dataset[i] }
        end
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
torch-rb-0.9.1 lib/torch/utils/data/subset.rb
torch-rb-0.9.0 lib/torch/utils/data/subset.rb
torch-rb-0.8.3 lib/torch/utils/data/subset.rb
torch-rb-0.8.2 lib/torch/utils/data/subset.rb
torch-rb-0.8.1 lib/torch/utils/data/subset.rb
torch-rb-0.8.0 lib/torch/utils/data/subset.rb
torch-rb-0.7.0 lib/torch/utils/data/subset.rb
torch-rb-0.6.0 lib/torch/utils/data/subset.rb
torch-rb-0.5.3 lib/torch/utils/data/subset.rb
torch-rb-0.5.2 lib/torch/utils/data/subset.rb
torch-rb-0.5.1 lib/torch/utils/data/subset.rb
torch-rb-0.5.0 lib/torch/utils/data/subset.rb
torch-rb-0.4.2 lib/torch/utils/data/subset.rb
torch-rb-0.4.1 lib/torch/utils/data/subset.rb
torch-rb-0.4.0 lib/torch/utils/data/subset.rb
torch-rb-0.3.7 lib/torch/utils/data/subset.rb
torch-rb-0.3.6 lib/torch/utils/data/subset.rb
torch-rb-0.3.5 lib/torch/utils/data/subset.rb
torch-rb-0.3.4 lib/torch/utils/data/subset.rb
torch-rb-0.3.3 lib/torch/utils/data/subset.rb