update GDAS
This commit is contained in:
@@ -89,7 +89,7 @@ def select_action(policy):
|
||||
return m.log_prob(action), action.cpu().tolist()
|
||||
|
||||
|
||||
def main(xargs):
|
||||
def main(xargs, nas_bench):
|
||||
assert torch.cuda.is_available(), 'CUDA is not available.'
|
||||
torch.backends.cudnn.enabled = True
|
||||
torch.backends.cudnn.benchmark = False
|
||||
@@ -128,12 +128,6 @@ def main(xargs):
|
||||
logger.log('eps : {:}'.format(eps))
|
||||
|
||||
# nas dataset load
|
||||
if xargs.arch_nas_dataset is None or not os.path.isfile(xargs.arch_nas_dataset):
|
||||
logger.log('Can not find the architecture dataset : {:}.'.format(xargs.arch_nas_dataset))
|
||||
nas_bench = None
|
||||
else:
|
||||
logger.log('{:} build NAS-Benchmark-API from {:}'.format(time_string(), xargs.arch_nas_dataset))
|
||||
nas_bench = AANASBenchAPI(xargs.arch_nas_dataset)
|
||||
logger.log('{:} use nas_bench : {:}'.format(time_string(), nas_bench))
|
||||
|
||||
# REINFORCE
|
||||
@@ -156,13 +150,12 @@ def main(xargs):
|
||||
|
||||
best_arch = policy.genotype()
|
||||
|
||||
if nas_bench is not None:
|
||||
info = nas_bench.query_by_arch( best_arch )
|
||||
if info is None: logger.log('Did not find this architecture : {:}.'.format(best_arch))
|
||||
else : logger.log('{:}'.format(info))
|
||||
info = nas_bench.query_by_arch( best_arch )
|
||||
if info is None: logger.log('Did not find this architecture : {:}.'.format(best_arch))
|
||||
else : logger.log('{:}'.format(info))
|
||||
logger.log('-'*100)
|
||||
|
||||
logger.close()
|
||||
return logger.log_dir, nas_bench.query_index_by_arch( best_arch )
|
||||
|
||||
|
||||
|
||||
@@ -183,7 +176,21 @@ if __name__ == '__main__':
|
||||
parser.add_argument('--save_dir', type=str, help='Folder to save checkpoints and log.')
|
||||
parser.add_argument('--arch_nas_dataset', type=str, help='The path to load the architecture dataset (tiny-nas-benchmark).')
|
||||
parser.add_argument('--print_freq', type=int, help='print frequency (default: 200)')
|
||||
parser.add_argument('--rand_seed', type=int, help='manual seed')
|
||||
parser.add_argument('--rand_seed', type=int, default=-1, help='manual seed')
|
||||
args = parser.parse_args()
|
||||
if args.rand_seed is None or args.rand_seed < 0: args.rand_seed = random.randint(1, 100000)
|
||||
main(args)
|
||||
#if args.rand_seed is None or args.rand_seed < 0: args.rand_seed = random.randint(1, 100000)
|
||||
if args.arch_nas_dataset is None or not os.path.isfile(args.arch_nas_dataset):
|
||||
nas_bench = None
|
||||
else:
|
||||
print ('{:} build NAS-Benchmark-API from {:}'.format(time_string(), args.arch_nas_dataset))
|
||||
nas_bench = AANASBenchAPI(args.arch_nas_dataset)
|
||||
if args.rand_seed < 0:
|
||||
save_dir, all_indexes, num = None, [], 500
|
||||
for i in range(num):
|
||||
print ('{:} : {:03d}/{:03d}'.format(time_string(), i, num))
|
||||
args.rand_seed = random.randint(1, 100000)
|
||||
save_dir, index = main(args, nas_bench)
|
||||
all_indexes.append( index )
|
||||
torch.save(all_indexes, save_dir / 'results.pth')
|
||||
else:
|
||||
main(args, nas_bench)
|
||||
|
Reference in New Issue
Block a user