| 110 | |
| 111 | |
| 112 | class VNLinearAndLeakyReLU(nn.Module): |
| 113 | def __init__(self, in_channels, out_channels, dim=5, share_nonlinearity=False, use_batchnorm='norm', |
| 114 | negative_slope=0.2): |
| 115 | super(VNLinearLeakyReLU, self).__init__() |
| 116 | self.dim = dim |
| 117 | self.share_nonlinearity = share_nonlinearity |
| 118 | self.use_batchnorm = use_batchnorm |
| 119 | self.negative_slope = negative_slope |
| 120 | |
| 121 | self.linear = VNLinear(in_channels, out_channels) |
| 122 | self.leaky_relu = VNLeakyReLU(out_channels, share_nonlinearity=share_nonlinearity, |
| 123 | negative_slope=negative_slope) |
| 124 | |
| 125 | # BatchNorm |
| 126 | self.use_batchnorm = use_batchnorm |
| 127 | if use_batchnorm != 'none': |
| 128 | self.batchnorm = VNBatchNorm(out_channels, dim=dim, mode=use_batchnorm) |
| 129 | |
| 130 | def forward(self, x): |
| 131 | ''' |
| 132 | x: point features of shape [B, N_feat, 3, N_samples, ...] |
| 133 | ''' |
| 134 | # Conv |
| 135 | x = self.linear(x) |
| 136 | # InstanceNorm |
| 137 | if self.use_batchnorm != 'none': |
| 138 | x = self.batchnorm(x) |
| 139 | # LeakyReLU |
| 140 | x_out = self.leaky_relu(x) |
| 141 | return x_out |
| 142 | |
| 143 | |
| 144 | class VNBatchNorm(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected