Module: TensorStream::Debugging

Extended by:
OpHelper
Included in:
TensorStream
Defined in:
lib/tensor_stream/debugging/debugging.rb

Instance Method Summary collapse

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

Instance Method Details

#add_check_numerics_opsObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tensor_stream/debugging/debugging.rb', line 5

def add_check_numerics_ops
  graph = TensorStream.get_default_graph
  nodes_to_process = graph.nodes.values.select { |node| node.is_a?(Operation) }

  nodes_to_process.each do |node|
    node.inputs = node.inputs.collect do |input|
      next if input.nil?
      next input if input.is_a?(Variable)

      if input.is_a?(Tensor) && TensorStream::Ops::FLOATING_POINT_TYPES.include?(input.data_type)
        TensorStream.check_numerics(input, "#{node.name}/#{input.name}", name: "check/#{node.name}/#{input.name}")
      else
        input
      end
    end
  end
end