Belle II Software development
bn Class Reference
Inheritance diagram for bn:

Public Member Functions

def __init__ (self, output_size, eps=1e-5, momentum=0.1, cross_replica=False, mybn=False)
 Constructor.
 
def forward (self, x)
 forward
 

Public Attributes

 output_size
 output size
 
 gain
 Prepare gain and bias layers.
 
 bias
 bias
 
 eps
 epsilon to avoid dividing by 0
 
 momentum
 Momentum.
 
 cross_replica
 Use cross-replica batchnorm?
 
 mybn
 Use my batchnorm?
 

Detailed Description

Normal, non-class-conditional BN

Definition at line 460 of file ieagan.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  output_size,
  eps = 1e-5,
  momentum = 0.1,
  cross_replica = False,
  mybn = False 
)

Constructor.

Definition at line 466 of file ieagan.py.

473 ):
474 super(bn, self).__init__()
475
476 self.output_size = output_size
477
478 self.gain = P(torch.ones(output_size), requires_grad=True)
479
480 self.bias = P(torch.zeros(output_size), requires_grad=True)
481
482 self.eps = eps
483
484 self.momentum = momentum
485
486 self.cross_replica = cross_replica
487
488 self.mybn = mybn
489
490 if mybn:
491 self.bn = myBN(output_size, self.eps, self.momentum)
492 # Register buffers if neither of the above
493 else:
494 self.register_buffer("stored_mean", torch.zeros(output_size))
495 self.register_buffer("stored_var", torch.ones(output_size))
496

Member Function Documentation

◆ forward()

def forward (   self,
  x 
)

forward

Definition at line 498 of file ieagan.py.

498 def forward(self, x):
499 if self.mybn:
500 gain = self.gain.view(1, -1, 1, 1)
501 bias = self.bias.view(1, -1, 1, 1)
502 return self.bn(x, gain=gain, bias=bias)
503 else:
504 return F.batch_norm(
505 x,
506 self.stored_mean,
507 self.stored_var,
508 self.gain,
509 self.bias,
510 self.training,
511 self.momentum,
512 self.eps,
513 )
514
515

Member Data Documentation

◆ bias

bias

bias

Definition at line 480 of file ieagan.py.

◆ bn

bn

Definition at line 491 of file ieagan.py.

◆ cross_replica

cross_replica

Use cross-replica batchnorm?

Definition at line 486 of file ieagan.py.

◆ eps

eps

epsilon to avoid dividing by 0

Definition at line 482 of file ieagan.py.

◆ gain

gain

Prepare gain and bias layers.

Definition at line 478 of file ieagan.py.

◆ momentum

momentum

Momentum.

Definition at line 484 of file ieagan.py.

◆ mybn

mybn

Use my batchnorm?

Definition at line 488 of file ieagan.py.

◆ output_size

output_size

output size

Definition at line 476 of file ieagan.py.


The documentation for this class was generated from the following file: