Skip to content

Commit

Permalink
refactor FairNASmutator
Browse files Browse the repository at this point in the history
  • Loading branch information
marsggbo committed May 13, 2022
1 parent f5337d4 commit 1d585d8
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions hyperbox/mutator/fairnas_mutator.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def prune_repeat_path(self, search_space):
memory = ()
idx = 0
for idx in range(self.num_path):
path = self.path2string(self[idx])
path = self.path2string(self.get_path_by_idx(idx))
if path not in memory:
memory += (path,)
for key in search_space:
Expand Down Expand Up @@ -180,15 +180,10 @@ def sample_search(self):
def sample_final(self):
return self.sample_search()

def __getitem__(self, idx):
def get_path_by_idx(self, idx):
path = {key: value[idx] for key, value in self.search_space.items()}
return path

def __len__(self):
for key, space in self.search_space.items():
self.num_path = len(space)
return len(space)

def path2string(self, path):
name = ''
for key, value in path.items():
Expand All @@ -206,7 +201,6 @@ def test(net, fm):
if fm.idx == fm.num_path:
print('new round\n=====================')
fm.reset()
net.sync_mask_for_all_cells(fm._cache)
print(f"{i+1}: {net.arch_encoding} {fm.idx}")

# singlepath lcm
Expand Down

0 comments on commit 1d585d8

Please sign in to comment.