MCPcopy Index your code
hub / github.com/ddbourgin/numpy-ml / SkipConnectionIdentityModule

Class SkipConnectionIdentityModule

numpy_ml/neural_nets/modules/modules.py:360–612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358
359
360class SkipConnectionIdentityModule(ModuleBase):
361 def __init__(
362 self,
363 out_ch,
364 kernel_shape1,
365 kernel_shape2,
366 stride1=1,
367 stride2=1,
368 act_fn=None,
369 epsilon=1e-5,
370 momentum=0.9,
371 optimizer=None,
372 init="glorot_uniform",
373 ):
374 """
375 A ResNet-like "identity" shortcut module.
376
377 Notes
378 -----
379 The identity module enforces `same` padding during each convolution to
380 ensure module output has same dims as its input.
381
382 .. code-block:: text
383
384 X -> Conv2D -> Act_fn -> BatchNorm2D -> Conv2D -> BatchNorm2D -> + -> Act_fn
385 \______________________________________________________________/
386
387 References
388 ----------
389 .. [1] He et al. (2015). "Deep residual learning for image
390 recognition." https://arxiv.org/pdf/1512.03385.pdf
391
392 Parameters
393 ----------
394 out_ch : int
395 The number of filters/kernels to compute in the first convolutional
396 layer.
397 kernel_shape1 : 2-tuple
398 The dimension of a single 2D filter/kernel in the first
399 convolutional layer.
400 kernel_shape2 : 2-tuple
401 The dimension of a single 2D filter/kernel in the second
402 convolutional layer.
403 stride1 : int
404 The stride/hop of the convolution kernels in the first
405 convolutional layer. Default is 1.
406 stride2 : int
407 The stride/hop of the convolution kernels in the second
408 convolutional layer. Default is 1.
409 act_fn : :doc:`Activation <numpy_ml.neural_nets.activations>` object or None
410 The activation function for computing Y[t]. If None, use the
411 identity :math:`f(x) = x` by default. Default is None.
412 epsilon : float
413 A small smoothing constant to use during
414 :class:`~numpy_ml.neural_nets.layers.BatchNorm2D` computation to
415 avoid divide-by-zero errors. Default is 1e-5.
416 momentum : float
417 The momentum term for the running mean/running std calculations in

Callers 1

Calls

no outgoing calls

Tested by 1