Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def add(self, *layers):
with self.init_scope():
for i, layer in enumerate(layers):
index = i + len(self.layers)
if isinstance(layer, chainer.Link):
setattr(self, "_sequential_%d" % index, layer)
if isinstance(layer, Residual):
for _index, _layer in enumerate(layer.layers):
if isinstance(_layer, chainer.Link):
setattr(self, "_sequential_{}_{}".format(index, _index), _layer)
self.layers += layers