Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument Parser updated to use action="store_true" instead of 0/1 for boolean arguments. #72

Merged
merged 8 commits into from
Sep 5, 2024
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

Optional multi-core/GPU support for statistics calculation in `create_parameter_weights.py`
- Argument Parser updated to use action="store_true" instead of 0/1 for boolean arguments.
(https://github.com/mllam/neural-lam/pull/72)
@ErikLarssonDev

- Optional multi-core/GPU support for statistics calculation in `create_parameter_weights.py`
[\#22](https://github.com/mllam/neural-lam/pull/22)
@sadamov

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Run `python -m neural_lam.create_mesh` with suitable options to generate the gra
The graphs used for the different models in the [paper](https://arxiv.org/abs/2309.17370) can be created as:

* **GC-LAM**: `python -m neural_lam.create_mesh --graph multiscale`
* **Hi-LAM**: `python -m neural_lam.create_mesh --graph hierarchical --hierarchical 1` (also works for Hi-LAM-Parallel)
* **Hi-LAM**: `python -m neural_lam.create_mesh --graph hierarchical --hierarchical` (also works for Hi-LAM-Parallel)
* **L1-LAM**: `python -m neural_lam.create_mesh --graph 1level --levels 1`

The graph-related files are stored in a directory called `graphs`.
Expand Down
10 changes: 4 additions & 6 deletions neural_lam/create_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,9 @@ def main(input_args=None):
)
parser.add_argument(
"--plot",
type=int,
default=0,
action="store_true",
help="If graphs should be plotted during generation "
"(default: 0 (false))",
"(default: False)",
)
parser.add_argument(
"--levels",
Expand All @@ -182,9 +181,8 @@ def main(input_args=None):
)
parser.add_argument(
"--hierarchical",
type=int,
default=0,
help="Generate hierarchical mesh graph (default: 0, no)",
action="store_true",
help="Generate hierarchical mesh graph (default: False)",
)
args = parser.parse_args(input_args)

Expand Down
5 changes: 2 additions & 3 deletions neural_lam/create_parameter_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,8 @@ def main():
)
parser.add_argument(
"--distributed",
type=int,
default=0,
help="Run the script in distributed mode (1) or not (0) (default: 0)",
action="store_true",
help="Run the script in distributed mode (default: False)",
)
args = parser.parse_args()
distributed = bool(args.distributed)
Expand Down
26 changes: 11 additions & 15 deletions neural_lam/train_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ def main(input_args=None):
)
parser.add_argument(
"--subset_ds",
type=int,
default=0,
action="store_true",
help="Use only a small subset of the dataset, for debugging"
"(default: 0=false)",
"(default: false)",
)
parser.add_argument(
"--seed", type=int, default=42, help="random seed (default: 42)"
Expand All @@ -71,10 +70,9 @@ def main(input_args=None):
)
parser.add_argument(
"--restore_opt",
type=int,
default=0,
action="store_true",
help="If optimizer state should be restored with model "
"(default: 0 (false))",
"(default: false)",
)
parser.add_argument(
"--precision",
Expand Down Expand Up @@ -118,11 +116,10 @@ def main(input_args=None):
)
parser.add_argument(
"--output_std",
type=int,
default=0,
action="store_true",
help="If models should additionally output std.-dev. per "
"output dimensions "
"(default: 0 (no))",
"(default: False (no))",
)

# Training options
Expand All @@ -135,10 +132,9 @@ def main(input_args=None):
)
parser.add_argument(
"--control_only",
type=int,
default=0,
action="store_true",
help="Train only on control member of ensemble data "
"(default: 0 (False))",
"(default: False)",
)
parser.add_argument(
"--loss",
Expand Down Expand Up @@ -233,7 +229,7 @@ def main(input_args=None):
pred_length=args.ar_steps,
split="train",
subsample_step=args.step_length,
subset=bool(args.subset_ds),
subset=args.subset_ds,
control_only=args.control_only,
),
args.batch_size,
Expand All @@ -247,7 +243,7 @@ def main(input_args=None):
pred_length=max_pred_length,
split="val",
subsample_step=args.step_length,
subset=bool(args.subset_ds),
subset=args.subset_ds,
control_only=args.control_only,
),
args.batch_size,
Expand Down Expand Up @@ -313,7 +309,7 @@ def main(input_args=None):
pred_length=max_pred_length,
split="test",
subsample_step=args.step_length,
subset=bool(args.subset_ds),
subset=args.subset_ds,
),
args.batch_size,
shuffle=False,
Expand Down
5 changes: 2 additions & 3 deletions plot_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ def main():
)
parser.add_argument(
"--show_axis",
type=int,
default=0,
help="If the axis should be displayed (default: 0 (No))",
action="store_true",
help="If the axis should be displayed (default: False)",
)

args = parser.parse_args()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mllam_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_load_reduced_meps_dataset(meps_example_reduced_filepath):
def test_create_graph_reduced_meps_dataset():
args = [
"--graph=hierarchical",
"--hierarchical=1",
"--hierarchical",
"--data_config=data/meps_example_reduced/data_config.yaml",
"--levels=2",
]
Expand Down
Loading