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

Public Member Functions

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

Public Attributes

 in_channels
 input channels
 
 out_channels = in_channels, out_channels
 input channels
 
 hidden_channels = self.in_channels // channel_ratio
 hidden channels
 
 which_conv
 which convolution
 
 which_bn = which_conv, which_bn
 which convolution
 
 activation = activation
 activation
 
 conv1
 conv1
 
 conv2 = self.which_conv(self.hidden_channels, self.hidden_channels)
 conv2
 
 conv3 = self.which_conv(self.hidden_channels, self.hidden_channels)
 conv3
 
 conv4
 conv4
 
 bn1 = self.which_bn(self.in_channels)
 bn1
 
 bn2 = self.which_bn(self.hidden_channels)
 bn2
 
 bn3 = self.which_bn(self.hidden_channels)
 bn3
 
 bn4 = self.which_bn(self.hidden_channels)
 bn4
 
 upsample = upsample
 upsample layers
 

Detailed Description

GBlock

Definition at line 1018 of file ieagan.py.

Constructor & Destructor Documentation

◆ __init__()

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

Constructor.

Definition at line 1022 of file ieagan.py.

1031 ):
1032 super(GBlock, self).__init__()
1033
1034
1035 self.in_channels, self.out_channels = in_channels, out_channels
1036
1037 self.hidden_channels = self.in_channels // channel_ratio
1038
1039 self.which_conv, self.which_bn = which_conv, which_bn
1040
1041 self.activation = activation
1042 # Conv layers
1043
1044 self.conv1 = self.which_conv(
1045 self.in_channels, self.hidden_channels, kernel_size=1, padding=0
1046 )
1047
1048 self.conv2 = self.which_conv(self.hidden_channels, self.hidden_channels)
1049
1050 self.conv3 = self.which_conv(self.hidden_channels, self.hidden_channels)
1051
1052 self.conv4 = self.which_conv(
1053 self.hidden_channels, self.out_channels, kernel_size=1, padding=0
1054 )
1055 # Batchnorm layers
1056
1057 self.bn1 = self.which_bn(self.in_channels)
1058
1059 self.bn2 = self.which_bn(self.hidden_channels)
1060
1061 self.bn3 = self.which_bn(self.hidden_channels)
1062
1063 self.bn4 = self.which_bn(self.hidden_channels)
1064
1065 self.upsample = upsample
1066

Member Function Documentation

◆ forward()

forward ( self,
x,
y )

forward

Definition at line 1068 of file ieagan.py.

1068 def forward(self, x, y):
1069 # Project down to channel ratio
1070 h = self.conv1(self.activation(self.bn1(x, y)))
1071 # Apply next BN-ReLU
1072 h = self.activation(self.bn2(h, y))
1073 # Drop channels in x if necessary
1074 if self.in_channels != self.out_channels:
1075 x = x[:, : self.out_channels]
1076 # Upsample both h and x at this point
1077 if self.upsample:
1078 h = self.upsample(h)
1079 x = self.upsample(x)
1080 # 3x3 convs
1081 h = self.conv2(h)
1082 h = self.conv3(self.activation(self.bn3(h, y)))
1083 # Final 1x1 conv
1084 h = self.conv4(self.activation(self.bn4(h, y)))
1085 return h + x
1086
1087

Member Data Documentation

◆ activation

activation = activation

activation

Definition at line 1041 of file ieagan.py.

◆ bn1

bn1 = self.which_bn(self.in_channels)

bn1

Definition at line 1057 of file ieagan.py.

◆ bn2

bn2 = self.which_bn(self.hidden_channels)

bn2

Definition at line 1059 of file ieagan.py.

◆ bn3

bn3 = self.which_bn(self.hidden_channels)

bn3

Definition at line 1061 of file ieagan.py.

◆ bn4

bn4 = self.which_bn(self.hidden_channels)

bn4

Definition at line 1063 of file ieagan.py.

◆ conv1

conv1
Initial value:
= self.which_conv(
self.in_channels, self.hidden_channels, kernel_size=1, padding=0
)

conv1

Definition at line 1044 of file ieagan.py.

◆ conv2

conv2 = self.which_conv(self.hidden_channels, self.hidden_channels)

conv2

Definition at line 1048 of file ieagan.py.

◆ conv3

conv3 = self.which_conv(self.hidden_channels, self.hidden_channels)

conv3

Definition at line 1050 of file ieagan.py.

◆ conv4

conv4
Initial value:
= self.which_conv(
self.hidden_channels, self.out_channels, kernel_size=1, padding=0
)

conv4

Definition at line 1052 of file ieagan.py.

◆ hidden_channels

hidden_channels = self.in_channels // channel_ratio

hidden channels

Definition at line 1037 of file ieagan.py.

◆ in_channels

in_channels

input channels

Definition at line 1035 of file ieagan.py.

◆ out_channels

out_channels = in_channels, out_channels

input channels

Definition at line 1035 of file ieagan.py.

◆ upsample

upsample = upsample

upsample layers

Definition at line 1065 of file ieagan.py.

◆ which_bn

which_bn = which_conv, which_bn

which convolution

Definition at line 1039 of file ieagan.py.

◆ which_conv

which_conv

which convolution

Definition at line 1039 of file ieagan.py.


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