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.
46
47
48
49
|
# File 'lib/dnn/core/merge_layers.rb', line 46
def initialize(axis: 1)
super()
@axis = axis
end
|
Instance Attribute Details
#axis ⇒ Object
Returns the value of attribute axis.
44
45
46
|
# File 'lib/dnn/core/merge_layers.rb', line 44
def axis
@axis
end
|
Instance Method Details
#backward(dy) ⇒ Object
57
58
59
|
# File 'lib/dnn/core/merge_layers.rb', line 57
def backward(dy)
dy.split([@x1_dim, @x1_dim + @x2_dim], axis: @axis)
end
|
#forward(x1, x2) ⇒ Object
51
52
53
54
55
|
# File 'lib/dnn/core/merge_layers.rb', line 51
def forward(x1, x2)
@x1_dim = x1.shape[@axis]
@x2_dim = x2.shape[@axis]
x1.concatenate(x2, axis: @axis)
end
|
#load_hash(hash) ⇒ Object
65
66
67
|
# File 'lib/dnn/core/merge_layers.rb', line 65
def load_hash(hash)
initialize(axis: hash[:axis])
end
|
#to_hash ⇒ Object
61
62
63
|
# File 'lib/dnn/core/merge_layers.rb', line 61
def to_hash
super(axis: @axis)
end
|