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

Public Member Functions

def __init__ (self, in_channels, out_channels, which_conv=SNConv2d, which_bn=bn, activation=None, upsample=None, channel_ratio=4)
 Constructor.
 
def forward (self, x, y)
 forward
 

Public Attributes

 out_channels
 input channels
 
 hidden_channels
 hidden channels
 
 which_bn
 which convolution
 
 activation
 activation
 
 conv1
 conv1
 
 conv2
 conv2
 
 conv3
 conv3
 
 conv4
 conv4
 
 bn1
 bn1
 
 bn2
 bn2
 
 bn3
 bn3
 
 bn4
 bn4
 
 upsample
 upsample layers
 

Detailed Description

GBlock

Definition at line 990 of file ieagan.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  in_channels,
  out_channels,
  which_conv = SNConv2d,
  which_bn = bn,
  activation = None,
  upsample = None,
  channel_ratio = 4 
)

Constructor.

Definition at line 994 of file ieagan.py.

1003 ):
1004 super(GBlock, self).__init__()
1005
1006
1007 self.in_channels, self.out_channels = in_channels, out_channels
1008
1009 self.hidden_channels = self.in_channels // channel_ratio
1010
1011 self.which_conv, self.which_bn = which_conv, which_bn
1012
1013 self.activation = activation
1014 # Conv layers
1015
1016 self.conv1 = self.which_conv(
1017 self.in_channels, self.hidden_channels, kernel_size=1, padding=0
1018 )
1019
1020 self.conv2 = self.which_conv(self.hidden_channels, self.hidden_channels)
1021
1022 self.conv3 = self.which_conv(self.hidden_channels, self.hidden_channels)
1023
1024 self.conv4 = self.which_conv(
1025 self.hidden_channels, self.out_channels, kernel_size=1, padding=0
1026 )
1027 # Batchnorm layers
1028
1029 self.bn1 = self.which_bn(self.in_channels)
1030
1031 self.bn2 = self.which_bn(self.hidden_channels)
1032
1033 self.bn3 = self.which_bn(self.hidden_channels)
1034
1035 self.bn4 = self.which_bn(self.hidden_channels)
1036
1037 self.upsample = upsample
1038

Member Function Documentation

◆ forward()

def forward (   self,
  x,
  y 
)

forward

Definition at line 1040 of file ieagan.py.

1040 def forward(self, x, y):
1041 # Project down to channel ratio
1042 h = self.conv1(self.activation(self.bn1(x, y)))
1043 # Apply next BN-ReLU
1044 h = self.activation(self.bn2(h, y))
1045 # Drop channels in x if necessary
1046 if self.in_channels != self.out_channels:
1047 x = x[:, : self.out_channels]
1048 # Upsample both h and x at this point
1049 if self.upsample:
1050 h = self.upsample(h)
1051 x = self.upsample(x)
1052 # 3x3 convs
1053 h = self.conv2(h)
1054 h = self.conv3(self.activation(self.bn3(h, y)))
1055 # Final 1x1 conv
1056 h = self.conv4(self.activation(self.bn4(h, y)))
1057 return h + x
1058
1059

Member Data Documentation

◆ activation

activation

activation

Definition at line 1013 of file ieagan.py.

◆ bn1

bn1

bn1

Definition at line 1029 of file ieagan.py.

◆ bn2

bn2

bn2

Definition at line 1031 of file ieagan.py.

◆ bn3

bn3

bn3

Definition at line 1033 of file ieagan.py.

◆ bn4

bn4

bn4

Definition at line 1035 of file ieagan.py.

◆ conv1

conv1

conv1

Definition at line 1016 of file ieagan.py.

◆ conv2

conv2

conv2

Definition at line 1020 of file ieagan.py.

◆ conv3

conv3

conv3

Definition at line 1022 of file ieagan.py.

◆ conv4

conv4

conv4

Definition at line 1024 of file ieagan.py.

◆ hidden_channels

hidden_channels

hidden channels

Definition at line 1009 of file ieagan.py.

◆ out_channels

out_channels

input channels

Definition at line 1007 of file ieagan.py.

◆ upsample

upsample

upsample layers

Definition at line 1037 of file ieagan.py.

◆ which_bn

which_bn

which convolution

Definition at line 1011 of file ieagan.py.


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