Views
No views yet
Testing_images and Training_images datasets from the CIS-5190-CIA repository.0.00010.5Testing_images and Training_images datasets from the CIS-5190-CIA repository.0.00130.5Testing_images and Training_images datasets from the CIS-5190-CIA repository.0.0010.5Testing_images_augmented and Training_images_augmented datasets from the CIS-5190-CIA repository.1class EnsembleModel(nn.Module):
2def __init__(self, models, num_models):
3super(EnsembleModel, self).__init__()
4self.models = nn.ModuleList(models)
5self.weights = nn.Parameter(torch.ones(num_models) / num_models)
6
7def forward(self, x):
8outputs = torch.stack([model(x) for model in self.models], dim=-1)
9weighted_output = torch.einsum('bij,j->bi', outputs, self.weights)
10return weighted_output1class Model1(nn.Module):
2def __init__(self, dropout):
3super(Model1, self).__init__()
4self.features = nn.Sequential(
5nn.Conv2d(3, 64, kernel_size=11, stride=4, padding=2),
6nn.ReLU(inplace=True),
7nn.MaxPool2d(kernel_size=3, stride=2),
8nn.Conv2d(64, 192, kernel_size=5, padding=2),
9nn.ReLU(inplace=True),
10nn.MaxPool2d(kernel_size=3, stride=2),
11nn.Conv2d(192, 384, kernel_size=3, padding=1),
12nn.ReLU(inplace=True),
13nn.Conv2d(384, 256, kernel_size=3, padding=1),
14nn.ReLU(inplace=True),
15nn.Conv2d(256, 256, kernel_size=3, padding=1),
16nn.ReLU(inplace=True),
17nn.MaxPool2d(kernel_size=3, stride=2),
18)
19self.classifier = nn.Sequential(
20nn.Dropout(p=dropout),
21nn.Linear(256 * 6 * 6, 1024),
22nn.ReLU(inplace=True),
23nn.Dropout(p=dropout),
24nn.Linear(1024, 512),
25nn.ReLU(inplace=True),
26nn.Linear(512, 2),
27)
28
29def forward(self, x):
30x = self.features(x)
31x = torch.flatten(x, 1)
32x = self.classifier(x)
33return x1class Model2(nn.Module):
2def __init__(self, num_blocks=3, dropout_rate=0.5):
3super(Model2, self).__init__()
4
5resnet = models.resnet34(pretrained=True)
6
7for param in list(resnet.parameters())[:num_blocks]:
8param.requires_grad = False
9
10self.features = nn.Sequential(*list(resnet.children())[:-2])
11self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
12
13self.classifier = nn.Sequential(
14nn.Flatten(),
15nn.Dropout(p=dropout_rate),
16nn.Linear(resnet.fc.in_features, 512),
17nn.ReLU(inplace=True),
18nn.Dropout(p=dropout_rate),
19nn.Linear(512, 2)
20)
21
22def forward(self, x):
23x = self.features(x)
24x = self.avgpool(x)
25x = self.classifier(x)
26return x1class InceptionModule(nn.Module):
2def __init__(self, in_channels, ch1x1, ch3x3_reduce, ch3x3, ch5x5_reduce, ch5x5, pool_proj):
3super(InceptionModule, self).__init__()
4
5self.branch1 = nn.Sequential(
6nn.Conv2d(in_channels, ch1x1, kernel_size=1),
7nn.ReLU(inplace=True)
8)
9self.branch2 = nn.Sequential(
10nn.Conv2d(in_channels, ch3x3_reduce, kernel_size=1),
11nn.ReLU(inplace=True),
12nn.Conv2d(ch3x3_reduce, ch3x3, kernel_size=3, padding=1),
13nn.ReLU(inplace=True)
14)
15
16self.branch3 = nn.Sequential(
17nn.Conv2d(in_channels, ch5x5_reduce, kernel_size=1),
18nn.ReLU(inplace=True),
19nn.Conv2d(ch5x5_reduce, ch5x5, kernel_size=5, padding=2),
20nn.ReLU(inplace=True)
21)
22
23self.branch4 = nn.Sequential(
24nn.MaxPool2d(kernel_size=3, stride=1, padding=1),
25nn.Conv2d(in_channels, pool_proj, kernel_size=1),
26nn.ReLU(inplace=True)
27)
28
29def forward(self, x):
30branch1 = self.branch1(x)
31branch2 = self.branch2(x)
32branch3 = self.branch3(x)
33branch4 = self.branch4(x)
34outputs = torch.cat([branch1, branch2, branch3, branch4], 1)
35return outputs
36
37
38class Model4(nn.Module):
39def __init__(self, dropout_rate=0.5):
40super(Model4, self).__init__()
41
42self.pre_layers = nn.Sequential(
43nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3),
44nn.ReLU(inplace=True),
45nn.MaxPool2d(kernel_size=3, stride=2, padding=1),
46nn.Conv2d(64, 192, kernel_size=3, padding=1),
47nn.ReLU(inplace=True),
48nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
49)
50
51self.inception1 = InceptionModule(192, 64, 96, 128, 16, 32, 32)
52self.inception2 = InceptionModule(256, 128, 128, 192, 32, 96, 64)
53
54self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
55
56self.inception3 = InceptionModule(480, 192, 96, 208, 16, 48, 64)
57self.inception4 = InceptionModule(512, 160, 112, 224, 24, 64, 64)
58
59self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
60self.classifier = nn.Sequential(
61nn.Flatten(),
62nn.Dropout(p=dropout_rate),
63nn.Linear(512, 1024),
64nn.ReLU(inplace=True),
65nn.Dropout(p=dropout_rate),
66nn.Linear(1024, 512),
67nn.ReLU(inplace=True),
68nn.Linear(512, 2)
69)
70
71def forward(self, x):
72x = self.pre_layers(x)
73x = self.inception1(x)
74x = self.inception2(x)
75x = self.maxpool(x)
76x = self.inception3(x)
77x = self.inception4(x)
78x = self.avgpool(x)
79x = self.classifier(x)
80return xRun_ensable_2 (2).ipynb, replace the line:dataset_test = load_dataset("gydou/released_img")1lat_std = 0.0006914493505038013
2lon_std = 0.0006539239061573955
3lat_mean = 39.9517411499467
4lon_mean = -75.19143213125122