Module: Tensorflow::PythonCompatability

Included in:
Tensorflow
Defined in:
lib/tensorflow/python_compatiblity.rb

Instance Method Summary collapse

Instance Method Details

#disable_eager_executionObject



17
18
19
# File 'lib/tensorflow/python_compatiblity.rb', line 17

def disable_eager_execution
  self.execution_mode = Tensorflow::GRAPH_MODE
end

#enable_eager_executionObject



21
22
23
# File 'lib/tensorflow/python_compatiblity.rb', line 21

def enable_eager_execution
  self.execution_mode = Tensorflow::EAGER_MODE
end

#global_variablesObject



25
26
27
28
29
30
31
# File 'lib/tensorflow/python_compatiblity.rb', line 25

def global_variables
  if ExecutionContext.eager?
    []
  else
    ExecutionContext.current.get_collection_ref(Graph::GraphKeys::GLOBAL_VARIABLES)
  end
end

#global_variables_initializerObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/tensorflow/python_compatiblity.rb', line 33

def global_variables_initializer
  if ExecutionContext.eager?
    RawOps.no_op
  else
    global_variables = ExecutionContext.current.get_collection_ref(Graph::GraphKeys::GLOBAL_VARIABLES)
    global_variables = Array(global_variables)
    if global_variables.length > 0
      self.variables_initializer(global_variables)
    end
  end
end

#variables_initializer(variables, name: 'init') ⇒ Object



45
46
47
48
49
50
51
# File 'lib/tensorflow/python_compatiblity.rb', line 45

def variables_initializer(variables, name: 'init')
  if ExecutionContext.eager?
    RawOps.no_op
  else
    Control.group(variables.map(&:initializer))
  end
end