Sha256: 7a28c548b9bcfcd6d05382a0a0b90d7bce09988f9a2dfb03848b9c1f3c649323

Contents?: true

Size: 537 Bytes

Versions: 37

Compression:

Stored size: 537 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
        alias_method :length, :size
        alias_method :count, :size
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
torch-rb-0.18.0 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.17.1 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.17.0 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.16.0 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.15.0 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.14.1 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.14.0 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.13.2 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.13.1 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.13.0 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.12.2 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.12.1 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.12.0 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.11.2 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.11.1 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.11.0 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.10.2 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.10.1 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.10.0 lib/torch/utils/data/tensor_dataset.rb
torch-rb-0.9.2 lib/torch/utils/data/tensor_dataset.rb