Class: DNN::MergeLayers::MergeLayer

Inherits:
Layers::Layer show all
Defined in:
lib/dnn/core/merge_layers.rb

Direct Known Subclasses

Add, Concatenate, Mul

Instance Attribute Summary

Attributes inherited from Layers::Layer

#input_shape, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Layers::Layer

#backward, #build, #built?, #forward, from_hash, #initialize, #load_hash, #output_shape, #to_hash

Constructor Details

This class inherits a constructor from DNN::Layers::Layer

Class Method Details

.call(x1, x2, *args) ⇒ Object



5
6
7
# File 'lib/dnn/core/merge_layers.rb', line 5

def self.call(x1, x2, *args)
  new(*args).call(x1, x2)
end

Instance Method Details

#call(input_tensor1, input_tensor2) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/dnn/core/merge_layers.rb', line 9

def call(input_tensor1, input_tensor2)
  x1 = input_tensor1.data
  x2 = input_tensor2.data
  prev_link1 = input_tensor1.link
  prev_link2 = input_tensor2.link
  build(x1.shape[1..-1]) unless built?
  y = forward(x1, x2)
  link = TwoInputLink.new(prev_link1, prev_link2, self)
  Tensor.new(y, link)
end