From 71f44fc629b015f67059d907162d733cc4cfa608 Mon Sep 17 00:00:00 2001 From: Xiangyu Shi Date: Mon, 25 Jul 2022 15:31:10 +0800 Subject: [PATCH 1/2] fix errors --- model_search.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/model_search.py b/model_search.py index f1f04c4..00c550c 100644 --- a/model_search.py +++ b/model_search.py @@ -153,7 +153,7 @@ def forward(self, data, discrete=False): x = F.dropout(x, p=self.dropout, training=self.training) jk = [] for i in range(self.num_layers): - x = self.layers[i](x, self.na_weights[0], edge_index) + x = self.layers[i](x, self.na_weights[i], edge_index) x = F.dropout(x, p=self.dropout, training=self.training) if self.args.fix_last and i == self.num_layers-1: jk += [x] @@ -200,11 +200,11 @@ def _initialize_alphas(self): num_la_ops = len(LA_PRIMITIVES) #self.alphas_normal = Variable(1e-3*torch.randn(k, num_ops).cuda(), requires_grad=True) - self.na_alphas = Variable(1e-3*torch.randn(3, num_na_ops).cuda(), requires_grad=True) + self.na_alphas = Variable(1e-3*torch.randn(self.num_layers, num_na_ops).cuda(), requires_grad=True) if self.args.fix_last: - self.sc_alphas = Variable(1e-3*torch.randn(2, num_sc_ops).cuda(), requires_grad=True) + self.sc_alphas = Variable(1e-3*torch.randn(self.num_layers-1, num_sc_ops).cuda(), requires_grad=True) else: - self.sc_alphas = Variable(1e-3*torch.randn(3, num_sc_ops).cuda(), requires_grad=True) + self.sc_alphas = Variable(1e-3*torch.randn(self.num_layers, num_sc_ops).cuda(), requires_grad=True) self.la_alphas = Variable(1e-3*torch.randn(1, num_la_ops).cuda(), requires_grad=True) self._arch_parameters = [ From 3c4fe6b3bc690c71b8eed425c11f60204fd05db8 Mon Sep 17 00:00:00 2001 From: Xiangyu Shi Date: Mon, 25 Jul 2022 15:52:55 +0800 Subject: [PATCH 2/2] fix errors --- model_search.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/model_search.py b/model_search.py index 00c550c..cab211f 100644 --- a/model_search.py +++ b/model_search.py @@ -263,19 +263,19 @@ def get_weights_from_arch(self, arch): num_la_ops = len(LA_PRIMITIVES) - na_alphas = Variable(torch.zeros(3, num_na_ops).cuda(), requires_grad=True) - sc_alphas = Variable(torch.zeros(2, num_sc_ops).cuda(), requires_grad=True) + na_alphas = Variable(torch.zeros(self.num_layers, num_na_ops).cuda(), requires_grad=True) + sc_alphas = Variable(torch.zeros(self.num_layers-1, num_sc_ops).cuda(), requires_grad=True) la_alphas = Variable(torch.zeros(1, num_la_ops).cuda(), requires_grad=True) - for i in range(3): + for i in range(self.num_layers): ind = NA_PRIMITIVES.index(arch_ops[i]) na_alphas[i][ind] = 1 - for i in range(3, 5): + for i in range(self.num_layers, self.num_layers * 2 - 1): ind = SC_PRIMITIVES.index(arch_ops[i]) - sc_alphas[i-3][ind] = 1 + sc_alphas[i-self.num_layers][ind] = 1 - ind = LA_PRIMITIVES.index(arch_ops[5]) + ind = LA_PRIMITIVES.index(arch_ops[self.num_layers*2-1]) la_alphas[0][ind] = 1 arch_parameters = [na_alphas, sc_alphas, la_alphas]