From 0c4f269fd9abc68f0248c2556e902e72ca39089f Mon Sep 17 00:00:00 2001 From: Dom <97384583+tosemml@users.noreply.github.com> Date: Mon, 21 Aug 2023 18:37:18 -0700 Subject: [PATCH 1/2] using str.join() --- networks/attentive_nas_dynamic_model.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/networks/attentive_nas_dynamic_model.py b/networks/attentive_nas_dynamic_model.py index 7628f33..3f7bbc7 100644 --- a/networks/attentive_nas_dynamic_model.py +++ b/networks/attentive_nas_dynamic_model.py @@ -264,8 +264,7 @@ def module_str(self): for stage_id, block_idx in enumerate(self.block_group_info): depth = self.runtime_depth[stage_id] active_idx = block_idx[:depth] - for idx in active_idx: - _str += self.blocks[idx].module_str + '\n' + _str = '\n'.join([self.blocks[idx].module_str for idx in active_idx]) if not self.use_v3_head: _str += self.last_conv.module_str + '\n' else: From 1162210f9faeea2d20054f83cac0815c23afa35b Mon Sep 17 00:00:00 2001 From: Dom <97384583+tosemml@users.noreply.github.com> Date: Mon, 21 Aug 2023 18:41:12 -0700 Subject: [PATCH 2/2] use .join --- networks/attentive_nas_static_model.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/networks/attentive_nas_static_model.py b/networks/attentive_nas_static_model.py index 0728322..4b71dd9 100644 --- a/networks/attentive_nas_static_model.py +++ b/networks/attentive_nas_static_model.py @@ -32,8 +32,7 @@ def forward(self, x): @property def module_str(self): _str = self.first_conv.module_str + '\n' - for block in self.blocks: - _str += block.module_str + '\n' + _str = '\n'.join([block.module_str for block in self.blocks]) #_str += self.last_conv.module_str + '\n' _str += self.classifier.module_str return _str