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.18.0 lib/torch/utils/data/subset.rb
torch-rb-0.17.1 lib/torch/utils/data/subset.rb
torch-rb-0.17.0 lib/torch/utils/data/subset.rb
torch-rb-0.16.0 lib/torch/utils/data/subset.rb
torch-rb-0.15.0 lib/torch/utils/data/subset.rb
torch-rb-0.14.1 lib/torch/utils/data/subset.rb
torch-rb-0.14.0 lib/torch/utils/data/subset.rb
torch-rb-0.13.2 lib/torch/utils/data/subset.rb
torch-rb-0.13.1 lib/torch/utils/data/subset.rb
torch-rb-0.13.0 lib/torch/utils/data/subset.rb
torch-rb-0.12.2 lib/torch/utils/data/subset.rb
torch-rb-0.12.1 lib/torch/utils/data/subset.rb
torch-rb-0.12.0 lib/torch/utils/data/subset.rb
torch-rb-0.11.2 lib/torch/utils/data/subset.rb
torch-rb-0.11.1 lib/torch/utils/data/subset.rb
torch-rb-0.11.0 lib/torch/utils/data/subset.rb
torch-rb-0.10.2 lib/torch/utils/data/subset.rb
torch-rb-0.10.1 lib/torch/utils/data/subset.rb
torch-rb-0.10.0 lib/torch/utils/data/subset.rb
torch-rb-0.9.2 lib/torch/utils/data/subset.rb