Add int search space

This commit is contained in:
D-X-Y
2021-03-18 16:02:55 +08:00
parent ece6ac5f41
commit 63c8bb9bc8
67 changed files with 5150 additions and 1474 deletions

View File

@@ -24,14 +24,24 @@ assert torch.cuda.is_available(), "torch.cuda is not available"
def main(args):
assert os.path.isdir(args.data_path), "invalid data-path : {:}".format(args.data_path)
assert os.path.isfile(args.checkpoint), "invalid checkpoint : {:}".format(args.checkpoint)
assert os.path.isdir(args.data_path), "invalid data-path : {:}".format(
args.data_path
)
assert os.path.isfile(args.checkpoint), "invalid checkpoint : {:}".format(
args.checkpoint
)
checkpoint = torch.load(args.checkpoint)
xargs = checkpoint["args"]
train_data, valid_data, xshape, class_num = get_datasets(xargs.dataset, args.data_path, xargs.cutout_length)
train_data, valid_data, xshape, class_num = get_datasets(
xargs.dataset, args.data_path, xargs.cutout_length
)
valid_loader = torch.utils.data.DataLoader(
valid_data, batch_size=xargs.batch_size, shuffle=False, num_workers=xargs.workers, pin_memory=True
valid_data,
batch_size=xargs.batch_size,
shuffle=False,
num_workers=xargs.workers,
pin_memory=True,
)
logger = PrintLogger()
@@ -41,7 +51,11 @@ def main(args):
logger.log("model ====>>>>:\n{:}".format(base_model))
logger.log("model information : {:}".format(base_model.get_message()))
logger.log("-" * 50)
logger.log("Params={:.2f} MB, FLOPs={:.2f} M ... = {:.2f} G".format(param, flop, flop / 1e3))
logger.log(
"Params={:.2f} MB, FLOPs={:.2f} M ... = {:.2f} G".format(
param, flop, flop / 1e3
)
)
logger.log("-" * 50)
logger.log("valid_data : {:}".format(valid_data))
optim_config = dict2config(checkpoint["optim-config"], logger)
@@ -54,23 +68,44 @@ def main(args):
try:
valid_loss, valid_acc1, valid_acc5 = valid_func(
valid_loader, network, criterion, optim_config, "pure-evaluation", xargs.print_freq_eval, logger
valid_loader,
network,
criterion,
optim_config,
"pure-evaluation",
xargs.print_freq_eval,
logger,
)
except:
_, valid_func = get_procedures("basic")
valid_loss, valid_acc1, valid_acc5 = valid_func(
valid_loader, network, criterion, optim_config, "pure-evaluation", xargs.print_freq_eval, logger
valid_loader,
network,
criterion,
optim_config,
"pure-evaluation",
xargs.print_freq_eval,
logger,
)
num_bytes = torch.cuda.max_memory_cached(next(network.parameters()).device) * 1.0
logger.log(
"***{:s}*** EVALUATION loss = {:.6f}, accuracy@1 = {:.2f}, accuracy@5 = {:.2f}, error@1 = {:.2f}, error@5 = {:.2f}".format(
time_string(), valid_loss, valid_acc1, valid_acc5, 100 - valid_acc1, 100 - valid_acc5
time_string(),
valid_loss,
valid_acc1,
valid_acc5,
100 - valid_acc1,
100 - valid_acc5,
)
)
logger.log(
"[GPU-Memory-Usage on {:} is {:} bytes, {:.2f} KB, {:.2f} MB, {:.2f} GB.]".format(
next(network.parameters()).device, int(num_bytes), num_bytes / 1e3, num_bytes / 1e6, num_bytes / 1e9
next(network.parameters()).device,
int(num_bytes),
num_bytes / 1e3,
num_bytes / 1e6,
num_bytes / 1e9,
)
)
logger.close()
@@ -79,6 +114,8 @@ def main(args):
if __name__ == "__main__":
parser = argparse.ArgumentParser("Evaluate-CNN")
parser.add_argument("--data_path", type=str, help="Path to dataset.")
parser.add_argument("--checkpoint", type=str, help="Choose between Cifar10/100 and ImageNet.")
parser.add_argument(
"--checkpoint", type=str, help="Choose between Cifar10/100 and ImageNet."
)
args = parser.parse_args()
main(args)