From d6ce421535abe92b66811d3a91f8ba53cd8632a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Fleuret?= Date: Wed, 19 Jul 2023 07:24:41 +0200 Subject: [PATCH] Update. --- main.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 19f918c..efcc0dd 100755 --- a/main.py +++ b/main.py @@ -59,15 +59,17 @@ parser.add_argument("--learning_rate", type=float, default=1e-4) parser.add_argument("--learning_rate_schedule", type=str, default="10: 2e-5,30: 4e-6") -parser.add_argument("--dim_model", type=int, default=512) +parser.add_argument("--model", type=str, default="37M") -parser.add_argument("--dim_keys", type=int, default=64) +parser.add_argument("--dim_model", type=int, default=None) -parser.add_argument("--dim_hidden", type=int, default=2048) +parser.add_argument("--dim_keys", type=int, default=None) -parser.add_argument("--nb_heads", type=int, default=8) +parser.add_argument("--dim_hidden", type=int, default=None) -parser.add_argument("--nb_blocks", type=int, default=12) +parser.add_argument("--nb_heads", type=int, default=None) + +parser.add_argument("--nb_blocks", type=int, default=None) parser.add_argument("--dropout", type=float, default=0.1) @@ -161,7 +163,7 @@ if args.result_dir is None: ###################################################################### -default_args = { +default_task_args = { "sandbox": { "nb_epochs": 50, "batch_size": 25, @@ -212,13 +214,53 @@ default_args = { }, } -if args.task in default_args: - for k, v in default_args[args.task].items(): +if args.task in default_task_args: + for k, v in default_task_args[args.task].items(): if getattr(args, k) is None: setattr(args, k, v) ###################################################################### +default_model_args = { + "17K": { + "dim_model": 32, + "dim_keys": 32, + "dim_hidden": 32, + "nb_heads": 2, + "nb_blocks": 2, + }, + "37M": { + "dim_model": 512, + "dim_keys": 64, + "dim_hidden": 2048, + "nb_heads": 8, + "nb_blocks": 12, + }, + "122M": { + "dim_model": 768, + "dim_keys": 64, + "dim_hidden": 2048, + "nb_heads": 8, + "nb_blocks": 24, + }, + "352M": { + "dim_model": 1024, + "dim_keys": 64, + "dim_hidden": 2048, + "nb_heads": 8, + "nb_blocks": 48, + }, +} + +if args.model in default_model_args: + for k, v in default_model_args[args.model].items(): + if getattr(args, k) is None: + setattr(args, k, v) +else: + raise ValueError(f"Unknown model {args.model}") + +###################################################################### + try: os.mkdir(args.result_dir) except FileExistsError: -- 2.39.5