Class: DNN::Layers::Layer

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

Overview

Super class of all optimizer classes.

Instance Method Summary collapse

Constructor Details

#initializeLayer

Returns a new instance of Layer.



8
9
10
# File 'lib/dnn/core/layers.rb', line 8

def initialize
  @built = false
end

Instance Method Details

#backwardObject

Backward propagation.



27
# File 'lib/dnn/core/layers.rb', line 27

def backward() end

#build(model) ⇒ Object

Build the layer.



13
14
15
16
# File 'lib/dnn/core/layers.rb', line 13

def build(model)
  @built = true
  @model = model
end

#built?Boolean

Does the layer have already been built?

Returns:

  • (Boolean)


19
20
21
# File 'lib/dnn/core/layers.rb', line 19

def built?
  @built
end

#forwardObject

Forward propagation.



24
# File 'lib/dnn/core/layers.rb', line 24

def forward() end

#prev_layerObject

Get the previous layer.



40
41
42
# File 'lib/dnn/core/layers.rb', line 40

def prev_layer
  @model.layers[@model.layers.index(self) - 1]
end

#shapeObject

Get the shape of the layer.



30
31
32
# File 'lib/dnn/core/layers.rb', line 30

def shape
  prev_layer.shape
end

#to_hash(hash) ⇒ Object

Layer to a hash.



35
36
37
# File 'lib/dnn/core/layers.rb', line 35

def to_hash(hash)
  {name: self.class.name}.merge(hash)
end