Class: Torch::Utils::Data::Subset
- Defined in:
- lib/torch/utils/data/subset.rb
Instance Method Summary collapse
- #[](idx) ⇒ Object
-
#initialize(dataset, indices) ⇒ Subset
constructor
A new instance of Subset.
- #length ⇒ Object (also: #size)
- #to_a ⇒ Object
Constructor Details
#initialize(dataset, indices) ⇒ Subset
Returns a new instance of Subset.
5 6 7 8 |
# File 'lib/torch/utils/data/subset.rb', line 5 def initialize(dataset, indices) @dataset = dataset @indices = indices end |
Instance Method Details
#[](idx) ⇒ Object
10 11 12 |
# File 'lib/torch/utils/data/subset.rb', line 10 def [](idx) @dataset[@indices[idx]] end |
#length ⇒ Object Also known as: size
14 15 16 |
# File 'lib/torch/utils/data/subset.rb', line 14 def length @indices.length end |
#to_a ⇒ Object
19 20 21 |
# File 'lib/torch/utils/data/subset.rb', line 19 def to_a @indices.map { |i| @dataset[i] } end |