Skip to content

Commit ad23d1c

Browse files
committed
adding Add layer
1 parent 4e7aff3 commit ad23d1c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

cnnumpy/layer.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ def __init__(self): pass
115115

116116
def forward(self, x):
117117
return np.concatenate(x, axis=1)
118+
119+
class Add(Layer):
120+
name = 'add'
121+
def __init__(self): pass
122+
123+
def forward(self, x):
124+
return sum(x)
118125

119126
class BatchNorm(Layer):
120127
name = 'batchnorm'
@@ -140,9 +147,10 @@ def load(self, buf):
140147
self.v[:] = buf[3*c:4*c]
141148
return self.c * 4
142149

150+
143151
layerkey = {'dense':Dense, 'conv':Conv2d, 'relu':ReLU, 'batchnorm':BatchNorm,
144152
'flatten':Flatten, 'sigmoid':Sigmoid, 'softmax': Softmax,
145-
'maxpool':Maxpool, 'upsample':UpSample, 'concat':Concatenate}
153+
'maxpool':Maxpool, 'upsample':UpSample, 'concat':Concatenate, 'add':Add}
146154

147155
if __name__ == "__main__":
148156
pass

0 commit comments

Comments
 (0)