class TensorStream::VariableScope

Attributes

initializer[RW]
name[RW]
reuse[RW]
used_names[R]

Public Class Methods

new(name: nil, reuse: nil, initializer: nil) click to toggle source
# File lib/tensor_stream/variable_scope.rb, line 7
def initialize(name: nil, reuse: nil, initializer: nil)
  @name = name
  @reuse = reuse
  @initializer = initializer
  @used_names = []
end

Public Instance Methods

get_variable(name, dtype: nil, shape: nil, initializer: nil, trainable: true, collections: nil, validate_shape: false) click to toggle source
# File lib/tensor_stream/variable_scope.rb, line 14
def get_variable(name, dtype: nil, shape: nil, initializer: nil, trainable: true, collections: nil, validate_shape: false)
  raise TensorStream::ValueError, "validate_shape=true and initializer does not have a defined shape" if validate_shape && !shape.nil && initializer.is_a?(Tensor)

  i_var(dtype || :float32, nil, shape, self, collections: collections, name: name, initializer: initializer, trainable: trainable)
end
register_name(name) click to toggle source
# File lib/tensor_stream/variable_scope.rb, line 20
def register_name(name)
  @used_names << name unless @used_names.include?(name)
end