lib/tensor_stream/utils.rb
##
# Creates a variable
# A variable maintains state across sessions
Creates a variable
A variable maintains state across sessions
Creates a variable A variable maintains state across sessions
def variable(value, name: nil, initializer: nil, graph: nil, dtype: nil, trainable: true)
      op = Operation.new(:assign, nil, value)
      common_options = {
        initializer: initializer || op,
        name: name,
        graph: graph,
        dtype: dtype,
        trainable: trainable
      }
      tensor = if value.is_a?(String)
                 TensorStream::Variable.new(dtype || :string, 0, [], get_variable_scope, common_options)
               elsif value.is_a?(Integer)
                 TensorStream::Variable.new(dtype || :int32, 0, [], get_variable_scope, common_options)
               elsif value.is_a?(Float)
                 TensorStream::Variable.new(dtype || :float32, 0, [], get_variable_scope, common_options)
               else
                 TensorStream::Variable.new(dtype || :float32, 0, nil, get_variable_scope, common_options)
               end
      op.inputs[0] = tensor
      tensor
    end
def variable ( value , name : nil , initializer : nil , graph : nil , dtype : nil , trainable : true ) op = Operation . new ( :assign , nil , value ) common_options = { initializer : initializer || op , name : name , graph : graph , dtype : dtype , trainable : trainable } tensor = if value . is_a? ( String ) TensorStream :: Variable . new ( dtype || :string , 0 , [ ] , get_variable_scope , common_options ) elsif value . is_a? ( Integer ) TensorStream :: Variable . new ( dtype || :int32 , 0 , [ ] , get_variable_scope , common_options ) elsif value . is_a? ( Float ) TensorStream :: Variable . new ( dtype || :float32 , 0 , [ ] , get_variable_scope , common_options ) else TensorStream :: Variable . new ( dtype || :float32 , 0 , nil , get_variable_scope , common_options ) end op . inputs [ 0 ] = tensor tensor end
Creates a variable
A variable maintains state across sessions
Creates a variable A variable maintains state across sessions
value
<not_specific>
name
<not_specific>
initializer
<not_specific>
graph
<not_specific>
dtype
<not_specific>
trainable
<not_specific>