Class: TensorStream::Placeholder

Inherits:
Tensor
  • Object
show all
Defined in:
lib/tensor_stream/placeholder.rb

Overview

Class that defines a TensorStream placeholder

Instance Attribute Summary

Attributes inherited from Tensor

#data_type, #given_name, #graph, #internal, #is_const, #name, #native_buffer, #op, #outputs, #rank, #shape, #source, #value

Instance Method Summary collapse

Methods inherited from Tensor

#auto_math, #breakpoint!, cast_dtype, #collect, #consumers, detect_type, #device, #dtype, #eval, #first, #internal?, #print!, reset_counters, #to_a, #to_f, #to_h, #to_i, #to_math, #to_s

Methods included from TensorMixins

#!=, #%, #*, #**, #+, #-, #-@, #/, #<, #<=, #==, #>, #>=, #[], #and, #cast, #ceil, #dot, #floor, #log, #matmul, #reduce, #reshape, #round, #var, #zero?

Methods included from OpHelper

#_op, #cons, #format_source, #fp_type?, #i_cons, #i_op, #i_var, #int_type?, #reduced_shape, #shape_eval, #shape_full_specified, #shapes_fully_specified_and_equal

Constructor Details

#initialize(data_type, rank, shape, options = {}) ⇒ Placeholder

Returns a new instance of Placeholder.



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

def initialize(data_type, rank, shape, options = {})
  setup_initial_state(options)

  @data_type = DataTypeUtils.norm_dtype(data_type.to_sym)
  @rank = rank
  @shape = TensorShape.new(shape, rank)
  @value = nil
  @is_const = false

  @name = [@graph.get_name_scope, options[:name] || build_name].compact.reject(&:empty?).join("/")
  @op = Graph.get_default_graph.add_op!(:placeholder, data_type: @data_type, shape: @shape, internal_name: @name)
end

Instance Method Details

#inspectObject



17
18
19
# File 'lib/tensor_stream/placeholder.rb', line 17

def inspect
  "Placeholder(#{@name} shape: #{@shape || "?"} data_type: #{@data_type})"
end