Class: DNN::Layers::HasParamLayer

Inherits:
Layer
  • Object
show all
Defined in:
lib/dnn/core/layers.rb

Direct Known Subclasses

BatchNormalization, Conv2D, Dense

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Layer

#backward, #built?, #forward, #prev_layer, #shape, #to_hash

Constructor Details

#initializeHasParamLayer

Returns a new instance of HasParamLayer.



50
51
52
53
54
# File 'lib/dnn/core/layers.rb', line 50

def initialize
  super
  @params = {}
  @grads = {}
end

Instance Attribute Details

#gradsObject (readonly)

Differential value of parameter of layer.



48
49
50
# File 'lib/dnn/core/layers.rb', line 48

def grads
  @grads
end

#paramsObject (readonly)

The parameters of the layer.



47
48
49
# File 'lib/dnn/core/layers.rb', line 47

def params
  @params
end

Instance Method Details

#build(model) ⇒ Object



56
57
58
59
# File 'lib/dnn/core/layers.rb', line 56

def build(model)
  super
  init_params
end

#updateObject

Update the parameters.



62
63
64
# File 'lib/dnn/core/layers.rb', line 62

def update
  @model.optimizer.update(self)
end