class Tensorflow::Data::Dataset
Constants
- DEFAULT_READER_BUFFER_SIZE_BYTES
Copied from Python code
Attributes
output_shapes[R]
TODO remove
output_types[R]
TODO remove
variant_tensor[R]
TODO remove
Public Class Methods
from_tensor_slices(tensors)
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 37 def self.from_tensor_slices(tensors) TensorSliceDataset.new(tensors) end
from_tensors(tensors)
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 33 def self.from_tensors(tensors) TensorDataset.new(tensors) end
new(variant_tensor)
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 41 def initialize(variant_tensor) @variant_tensor = variant_tensor end
to_tensor_array(values)
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 12 def self.to_tensor_array(values) case values when Numo::NArray [Tensor.new(values)] when Tensor [values] when Array values.to_a.map do |v| if v.is_a?(Tensor) v else Tensor.new(v) end end when Graph::Operation [values] else raise(Error::UnimplementedError, "Unsupported dataset element: #{values}") end end
Public Instance Methods
batch(batch_size, drop_remainder: false)
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 53 def batch(batch_size, drop_remainder: false) BatchDataset.new(self, batch_size, drop_remainder) end
data()
click to toggle source
!!! DEBUG method. You don't want to use this method it because it iterates over the entire dataset and reads it into a ruby array in memory
# File lib/tensorflow/data/dataset.rb, line 85 def data self.map do |slice| if slice.is_a?(Array) slice.map do |tensor| tensor.value end else slice.value end end end
each() { |values| ... }
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 69 def each iterator, deleter = RawOps.anonymous_iterator_v2(output_types: @output_types, output_shapes: @output_shapes) RawOps.make_iterator(@variant_tensor, iterator) begin loop do values = RawOps.iterator_get_next_sync(iterator, output_types: @output_types, output_shapes: @output_shapes) yield values end rescue Error::OutOfRangeError end ensure RawOps.delete_iterator(iterator, deleter) if iterator end
make_initializable_iterator(shared_name: '')
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 65 def make_initializable_iterator(shared_name: '') InitializableIterator.new(self, shared_name: shared_name) end
make_one_shot_iterator()
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 61 def make_one_shot_iterator OneShotIterator.new(self) end
map_func(func)
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 97 def map_func(func) MapDataset.new(self, func) end
repeat(count)
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 101 def repeat(count) RepeatDataset.new(self, 3) end
shuffle(buffer_size)
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 57 def shuffle(buffer_size) ShuffleDataset.new(self, buffer_size) end
to_ptr()
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 45 def to_ptr @variant_tensor.to_ptr end
with_options(options)
click to toggle source
# File lib/tensorflow/data/dataset.rb, line 49 def with_options(options) end