Class: Tensorflow::Data::ShuffleDataset

Inherits:
Dataset
  • Object
show all
Defined in:
lib/tensorflow/data/shuffle_dataset.rb

Constant Summary

Constants inherited from Dataset

Dataset::DEFAULT_READER_BUFFER_SIZE_BYTES

Instance Attribute Summary

Attributes inherited from Dataset

#output_shapes, #output_types, #variant_tensor

Instance Method Summary collapse

Methods inherited from Dataset

#batch, #data, #each, from_tensor_slices, from_tensors, #make_initializable_iterator, #make_one_shot_iterator, #map_func, #repeat, #shuffle, #to_ptr, to_tensor_array, #with_options

Constructor Details

#initialize(input_dataset, buffer_size) ⇒ ShuffleDataset

Returns a new instance of ShuffleDataset.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/tensorflow/data/shuffle_dataset.rb', line 4

def initialize(input_dataset, buffer_size)
  @input_dataset = input_dataset
  @output_types = input_dataset.output_types
  @output_shapes = input_dataset.output_shapes

  buffer_size = Tensor.new(buffer_size, dtype: :int64)
  seed = Tensor.new(::Random.rand(100_000_000), dtype: :int64)
  seed2 = Tensor.new(::Random.rand(100_000_000), dtype: :int64)

  variant_tensor = RawOps.shuffle_dataset(input_dataset.variant_tensor,
                                          buffer_size,
                                          seed,
                                          seed2,
                                          output_types: @output_types,
                                          output_shapes: @output_shapes)
  super(variant_tensor)
end