Sha256: 073cbd6b2d0621b8a75781fe175c0bee2f52e65d89c93d6077247c871f1b0238

Contents?: true

Size: 466 Bytes

Versions: 10

Compression:

Stored size: 466 Bytes

Contents

module Torch
  module Utils
    module Data
      class TensorDataset < Dataset
        def initialize(*tensors)
          unless tensors.all? { |t| t.size(0) == tensors[0].size(0) }
            raise Error, "Tensors must all have same dim 0 size"
          end
          @tensors = tensors
        end

        def [](index)
          @tensors.map { |t| t[index] }
        end

        def size
          @tensors[0].size(0)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
torch-rb-0.3.5 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.3.4 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.3.3 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.3.2 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.3.1 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.3.0 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.2.7 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.2.6 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.2.5 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.2.4 lib/torch/utils/data/tensor_dataset.rb