(self)
| 92 | |
| 93 | class Net(nn.Module): |
| 94 | def __init__(self): |
| 95 | super(Net, self).__init__() |
| 96 | self.conv1 = nn.Conv2d(1, 10, kernel_size=5) |
| 97 | self.conv2 = nn.Conv2d(10, 20, kernel_size=5) |
| 98 | self.conv2_drop = nn.Dropout2d() |
| 99 | self.fc1 = nn.Linear(320, 50) |
| 100 | self.fc2 = nn.Linear(50, 10) |
| 101 | |
| 102 | # Spatial transformer localization-network |
| 103 | self.localization = nn.Sequential( |
| 104 | nn.Conv2d(1, 8, kernel_size=7), |
| 105 | nn.MaxPool2d(2, stride=2), |
| 106 | nn.ReLU(True), |
| 107 | nn.Conv2d(8, 10, kernel_size=5), |
| 108 | nn.MaxPool2d(2, stride=2), |
| 109 | nn.ReLU(True) |
| 110 | ) |
| 111 | |
| 112 | # Regressor for the 3 * 2 affine matrix |
| 113 | self.fc_loc = nn.Sequential( |
| 114 | nn.Linear(10 * 3 * 3, 32), |
| 115 | nn.ReLU(True), |
| 116 | nn.Linear(32, 3 * 2) |
| 117 | ) |
| 118 | |
| 119 | # Initialize the weights/bias with identity transformation |
| 120 | self.fc_loc[2].weight.data.zero_() |
| 121 | self.fc_loc[2].bias.data.copy_(torch.tensor([1, 0, 0, 0, 1, 0], dtype=torch.float)) |
| 122 | |
| 123 | # Spatial transformer network forward function |
| 124 | def stn(self, x): |
nothing calls this directly
no outgoing calls
no test coverage detected