How to use the sru.nn.Residual function in sru

To help you get started, we’ve selected a few sru examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github musyoku / chainer-sru / sru / nn.py View on Github external
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