Class: DNN::MergeLayers::Concatenate
Instance Attribute Summary collapse
#input_shape, #name
Instance Method Summary
collapse
Methods inherited from MergeLayer
call, #call
#build, #built?, #call, call, from_hash, #output_shape
Constructor Details
#initialize(axis: 1) ⇒ Concatenate
Returns a new instance of Concatenate.
45
46
47
48
|
# File 'lib/dnn/core/merge_layers.rb', line 45
def initialize(axis: 1)
super()
@axis = axis
end
|
Instance Attribute Details
#axis ⇒ Object
Returns the value of attribute axis.
43
44
45
|
# File 'lib/dnn/core/merge_layers.rb', line 43
def axis
@axis
end
|
Instance Method Details
#backward(dy) ⇒ Object
56
57
58
|
# File 'lib/dnn/core/merge_layers.rb', line 56
def backward(dy)
dy.split([@x1_dim, @x1_dim + @x2_dim], axis: @axis)
end
|
#forward(x1, x2) ⇒ Object
50
51
52
53
54
|
# File 'lib/dnn/core/merge_layers.rb', line 50
def forward(x1, x2)
@x1_dim = x1.shape[@axis]
@x2_dim = x2.shape[@axis]
x1.concatenate(x2, axis: @axis)
end
|
#load_hash(hash) ⇒ Object
64
65
66
|
# File 'lib/dnn/core/merge_layers.rb', line 64
def load_hash(hash)
initialize(axis: hash[:axis])
end
|
#to_hash ⇒ Object
60
61
62
|
# File 'lib/dnn/core/merge_layers.rb', line 60
def to_hash
super(axis: @axis)
end
|