Belle II Software  release-08-01-10
ResidualBlock Class Reference

Class for the residual block layer. More...

Inheritance diagram for ResidualBlock:
Collaboration diagram for ResidualBlock:

Public Member Functions

def __init__ (self, ninput, noutput, upsample=True)
 Constructor to create a new residual block layer.
 
def forward (self, x)
 Function to perform a forward pass. More...
 

Public Attributes

 upsample
 Whether to double the height and width of input.
 
 conv
 Convolutional layer in the shortcut branch.
 
 norm1
 First batch normalization layer in the residual branch.
 
 conv1
 First convolutional layer in the residual branch.
 
 norm2
 Second batch normalization layer in the residual branch.
 
 conv2
 Second convolutional layer in the residual branch.
 

Detailed Description

Class for the residual block layer.

Residual block layer.

Definition at line 19 of file resnet.py.

Member Function Documentation

◆ forward()

def forward (   self,
  x 
)

Function to perform a forward pass.

Compute the layer output for a given input.

Definition at line 39 of file resnet.py.

39  def forward(self, x):
40  """Compute the layer output for a given input."""
41  # residual branch
42  h = x
43  h = self.norm1(h)
44  h.relu_()
45  if self.upsample:
46  h = F.interpolate(h, mode="nearest", scale_factor=2)
47  h = self.conv1(h)
48  h = self.norm2(h)
49  h.relu_()
50  h = self.conv2(h)
51  # shortcut branch
52  if self.upsample:
53  x = F.interpolate(x, mode="nearest", scale_factor=2)
54  if self.conv:
55  x = self.conv(x)
56  # return sum of both
57  return h + x
58 

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