Class: DNN::Layers::Layer

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

Overview

Super class of all optimizer classes.

Instance Attribute Summary collapse

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 Attribute Details

#input_shapeObject (readonly)

Returns the value of attribute input_shape.



6
7
8
# File 'lib/dnn/core/layers.rb', line 6

def input_shape
  @input_shape
end

Instance Method Details

#backward(dout) ⇒ Object

Backward propagation.

Raises:

  • (NotImplementedError)


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

def backward(dout)
  raise NotImplementedError.new("Class '#{self.class.name}' has implement method 'update'")
end

#build(input_shape) ⇒ Object

Build the layer.



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

def build(input_shape)
  @input_shape = input_shape
  @built = true
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

#forward(x) ⇒ Object

Forward propagation.

Raises:

  • (NotImplementedError)


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

def forward(x)
  raise NotImplementedError.new("Class '#{self.class.name}' has implement method 'forward'")
end

#output_shapeObject



33
34
35
# File 'lib/dnn/core/layers.rb', line 33

def output_shape
  @input_shape
end

#to_hash(merge_hash = nil) ⇒ Object

Layer to a hash.



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

def to_hash(merge_hash = nil)
  hash = {class: self.class.name}
  hash.merge!(merge_hash) if merge_hash
  hash
end