Class: DNN::Layers::MergeLayer

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

Direct Known Subclasses

Add, Concatenate, Div, Dot, Mul, Sub

Instance Attribute Summary

Attributes inherited from Layer

#input_shape, #output_shape

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Layer

#<<, #build, #built?, #clean, #compute_output_shape, #forward, from_hash, #initialize, #load_hash, #to_hash

Constructor Details

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

Class Method Details

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



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

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

Instance Method Details

#call(input1, input2) ⇒ Object



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

def call(input1, input2)
  input1 = Tensor.convert(input1) if !input1.is_a?(Tensor) && !input1.is_a?(Param)
  input2 = Tensor.convert(input2) if !input2.is_a?(Tensor) && !input2.is_a?(Param)
  if input1.data.is_a?(Xumo::NArray)
    build(input1.data.shape[1..-1]) unless built?
  else
    build([1]) unless built?
  end
  forward(input1, input2)
end