Module: DNN::Layers::LayerNode

Instance Method Summary collapse

Instance Method Details

#backward_node(*dys) ⇒ Object

Raises:

  • (NotImplementedError)


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

def backward_node(*dys)
  raise NotImplementedError, "Class '#{self.class.name}' has implement method 'backward_node'"
end

#forward(*inputs) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/dnn/core/layers/basic_layers.rb', line 5

def forward(*inputs)
  xs = inputs.map(&:data)
  prevs = inputs.map { |input| input.is_a?(Tensor) ? input.link : input }
  ys = forward_node(*xs)
  num_outputs = (ys.is_a?(Array) ? ys.length : 1)
  link = Link.new(prevs: prevs, layer_node: self, num_outputs: num_outputs)
  prevs.map { |prev| prev.next = link if prev.is_a?(Link) }
  Tensor.convert(ys, link)
end

#forward_node(*xs) ⇒ Object

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/dnn/core/layers/basic_layers.rb', line 15

def forward_node(*xs)
  raise NotImplementedError, "Class '#{self.class.name}' has implement method 'forward_node'"
end