in sampler/attentive_nas_sampler.py [0:0]
def sample_archs_according_to_flops(self, target_flops, n_samples=1, max_trials=100, return_flops=True, return_trials=False):
archs = []
#for _ in range(n_samples):
while len(archs) < n_samples:
for _trial in range(max_trials+1):
arch = {}
arch['resolution'] = sample_helper(target_flops, self.prob_map['resolution'])
for k in ['width', 'kernel_size', 'depth', 'expand_ratio']:
arch[k] = []
for idx in sorted(list(self.prob_map[k].keys())):
arch[k].append(sample_helper(target_flops, self.prob_map[k][idx]))
if self.model:
self.model.set_active_subnet(**arch)
flops = self.model.compute_active_subnet_flops()
if return_flops:
arch['flops'] = flops
if round_flops(flops, self.discretize_step) == target_flops:
break
else:
raise NotImplementedError
#accepte the sample anyway
archs.append(arch)
return archs