Sha256: 3303858af89d0719b9f1dc752ada9b29ec32cc02cf2167951c8fd415bc991563

Contents?: true

Size: 848 Bytes

Versions: 9

Compression:

Stored size: 848 Bytes

Contents

module TensorStream
  class VariableScope
    include OpHelper
    attr_accessor :name, :reuse, :initializer
    attr_reader :used_names

    def initialize(name: nil, reuse: nil, initializer: nil)
      @name = name
      @reuse = reuse
      @initializer = initializer
      @used_names = []
    end

    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

    def register_name(name)
      @used_names << name unless @used_names.include?(name)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tensor_stream-1.0.9 lib/tensor_stream/variable_scope.rb
tensor_stream-1.0.8 lib/tensor_stream/variable_scope.rb
tensor_stream-1.0.7 lib/tensor_stream/variable_scope.rb
tensor_stream-1.0.6 lib/tensor_stream/variable_scope.rb
tensor_stream-1.0.5 lib/tensor_stream/variable_scope.rb
tensor_stream-1.0.4 lib/tensor_stream/variable_scope.rb
tensor_stream-1.0.3 lib/tensor_stream/variable_scope.rb
tensor_stream-1.0.2 lib/tensor_stream/variable_scope.rb
tensor_stream-1.0.1 lib/tensor_stream/variable_scope.rb