Class: TorchData::DataPipes::Iter::Util::SplitterIterator
- Inherits:
-
IterDataPipe
- Object
- TorchData::DataPipes::Iter::Util::SplitterIterator
- Defined in:
- lib/torchdata/data_pipes/iter/util/random_splitter.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(main_datapipe, target) ⇒ SplitterIterator
constructor
A new instance of SplitterIterator.
- #length ⇒ Object
- #override_seed(seed) ⇒ Object
Constructor Details
#initialize(main_datapipe, target) ⇒ SplitterIterator
Returns a new instance of SplitterIterator.
89 90 91 92 |
# File 'lib/torchdata/data_pipes/iter/util/random_splitter.rb', line 89 def initialize(main_datapipe, target) @main_datapipe = main_datapipe @target = target end |
Instance Method Details
#each ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/torchdata/data_pipes/iter/util/random_splitter.rb', line 94 def each @main_datapipe.reset @main_datapipe.source_datapipe.each do |sample| if @main_datapipe.draw == @target yield sample end end end |
#length ⇒ Object
107 108 109 |
# File 'lib/torchdata/data_pipes/iter/util/random_splitter.rb', line 107 def length @main_datapipe.get_length(@target) end |
#override_seed(seed) ⇒ Object
103 104 105 |
# File 'lib/torchdata/data_pipes/iter/util/random_splitter.rb', line 103 def override_seed(seed) @main_datapipe.override_seed(seed) end |