Class: DNN::Layers::Concatenate
Instance Attribute Summary collapse
Attributes inherited from Layer
#input_shape, #output_shape
Instance Method Summary
collapse
Methods included from LayerNode
#forward
Methods inherited from MergeLayer
call, #call
Methods inherited from Layer
#<<, #build, #built?, #call, call, #clean, #compute_output_shape, #forward, from_hash
Constructor Details
#initialize(axis: 1) ⇒ Concatenate
Returns a new instance of Concatenate.
26
27
28
29
|
# File 'lib/dnn/core/layers/merge_layers.rb', line 26
def initialize(axis: 1)
super()
@axis = axis
end
|
Instance Attribute Details
#axis ⇒ Object
Returns the value of attribute axis.
24
25
26
|
# File 'lib/dnn/core/layers/merge_layers.rb', line 24
def axis
@axis
end
|
Instance Method Details
#backward_node(dy) ⇒ Object
37
38
39
|
# File 'lib/dnn/core/layers/merge_layers.rb', line 37
def backward_node(dy)
dy.split([@x1_dim, @x1_dim + @x2_dim], axis: @axis)
end
|
#forward_node(x1, x2) ⇒ Object
31
32
33
34
35
|
# File 'lib/dnn/core/layers/merge_layers.rb', line 31
def forward_node(x1, x2)
@x1_dim = x1.shape[@axis]
@x2_dim = x2.shape[@axis]
x1.concatenate(x2, axis: @axis)
end
|
#load_hash(hash) ⇒ Object
45
46
47
|
# File 'lib/dnn/core/layers/merge_layers.rb', line 45
def load_hash(hash)
initialize(axis: hash[:axis])
end
|
#to_hash ⇒ Object
41
42
43
|
# File 'lib/dnn/core/layers/merge_layers.rb', line 41
def to_hash
super(axis: @axis)
end
|