lib/tensorflow/variable.rb in tensorflow-0.1.0 vs lib/tensorflow/variable.rb in tensorflow-0.1.1

- old
+ new

@@ -1,32 +1,32 @@ module TensorFlow class Variable def initialize(initial_value, dtype: nil) - @dtype = dtype || Utils.infer_type(initial_value) - @pointer = TensorFlow.var_handle_op(type_enum, nil, shared_name: TensorFlow.send(:default_context).shared_name) + @dtype = dtype || Utils.infer_type(Array(initial_value).flatten) + @pointer = RawOps.var_handle_op(dtype: type_enum, shape: [], shared_name: Utils.default_context.shared_name) assign(initial_value) end def assign(value) value = TensorFlow.convert_to_tensor(value, dtype: @dtype) - TensorFlow.assign_variable_op(@pointer, value) + RawOps.assign_variable_op(resource: @pointer, value: value) self end def assign_add(value) value = TensorFlow.convert_to_tensor(value, dtype: @dtype) - TensorFlow.assign_add_variable_op(@pointer, value) + RawOps.assign_add_variable_op(resource: @pointer, value: value) self end def assign_sub(value) value = TensorFlow.convert_to_tensor(value, dtype: @dtype) - TensorFlow.assign_sub_variable_op(@pointer, value) + RawOps.assign_sub_variable_op(resource: @pointer, value: value) self end def read_value - TensorFlow.read_variable_op(@pointer, type_enum) + RawOps.read_variable_op(resource: @pointer, dtype: type_enum) end def +(other) v = Variable.new(read_value.value, dtype: @dtype) v.assign_add(other).read_value