Class: DNN::Layers::Concatenate
Instance Attribute Summary collapse
Attributes inherited from Layer
#input_shape
Instance Method Summary
collapse
Methods inherited from MergeLayer
call, #call
#backward, #forward
Methods inherited from Layer
#build, #built?, #call, call, #clean, #forward, from_hash, #output_shape
Constructor Details
#initialize(axis: 1) ⇒ Concatenate
Returns a new instance of Concatenate.
50
51
52
53
|
# File 'lib/dnn/core/layers/merge_layers.rb', line 50
def initialize(axis: 1)
super()
@axis = axis
end
|
Instance Attribute Details
#axis ⇒ Object
Returns the value of attribute axis.
48
49
50
|
# File 'lib/dnn/core/layers/merge_layers.rb', line 48
def axis
@axis
end
|
Instance Method Details
#backward_node(dy) ⇒ Object
61
62
63
|
# File 'lib/dnn/core/layers/merge_layers.rb', line 61
def backward_node(dy)
dy.split([@x1_dim, @x1_dim + @x2_dim], axis: @axis)
end
|
#forward_node(x1, x2) ⇒ Object
55
56
57
58
59
|
# File 'lib/dnn/core/layers/merge_layers.rb', line 55
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
69
70
71
|
# File 'lib/dnn/core/layers/merge_layers.rb', line 69
def load_hash(hash)
initialize(axis: hash[:axis])
end
|
#to_hash ⇒ Object
65
66
67
|
# File 'lib/dnn/core/layers/merge_layers.rb', line 65
def to_hash
super(axis: @axis)
end
|