Class: Torch::Utils::Data::DataPipes::Iter::IterableWrapper
- Inherits:
-
Torch::Utils::Data::DataPipes::IterDataPipe
- Object
- Torch::Utils::Data::Dataset
- IterableDataset
- Torch::Utils::Data::DataPipes::IterDataPipe
- Torch::Utils::Data::DataPipes::Iter::IterableWrapper
- Defined in:
- lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(iterable, deepcopy: true) ⇒ IterableWrapper
constructor
A new instance of IterableWrapper.
- #length ⇒ Object
Methods inherited from Torch::Utils::Data::DataPipes::IterDataPipe
functional_datapipe, functions, register_datapipe_as_function, #reset
Constructor Details
#initialize(iterable, deepcopy: true) ⇒ IterableWrapper
Returns a new instance of IterableWrapper.
7 8 9 10 |
# File 'lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb', line 7 def initialize(iterable, deepcopy: true) @iterable = iterable @deepcopy = deepcopy end |
Instance Method Details
#each ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb', line 12 def each source_data = @iterable if @deepcopy source_data = Marshal.load(Marshal.dump(@iterable)) end source_data.each do |data| yield data end end |
#length ⇒ Object
22 23 24 |
# File 'lib/torch/utils/data/data_pipes/iter/iterable_wrapper.rb', line 22 def length @iterable.length end |