Class: Tensorflow::Data::BatchDataset

Inherits:
Dataset
  • Object
show all
Defined in:
lib/tensorflow/data/batch_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, batch_size, drop_remainder) ⇒ BatchDataset

Returns a new instance of BatchDataset.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/tensorflow/data/batch_dataset.rb', line 4

def initialize(input_dataset, batch_size, drop_remainder)
  @input_dataset = input_dataset
  @output_types = input_dataset.output_types
  @output_shapes = input_dataset.output_shapes.map do |shape|
    shape.unshift(-1)
  end

  batch_size = Tensor.new(batch_size, dtype: :int64)
  variant_tensor = RawOps.batch_dataset_v2(input_dataset.variant_tensor, batch_size, drop_remainder,
                                           output_types: @output_types, output_shapes: @output_shapes)
  super(variant_tensor)
end