the-full-stack / fsdl-text-recognizer-2021-labs

Complete deep learning project developed in Full Stack Deep Learning, Spring 2021
https://bit.ly/berkeleyfsdl
MIT License
452 stars 281 forks source link

How does parser pick up additional command-line flags? #44

Closed qAp closed 2 years ago

qAp commented 2 years ago

In _setup_parser, the parser picks up arguments from the default data_class, which is MNIST.

EMNISTLines has additional arguments like max_length and max_overlap.

But because

parser = _setup_parser()

is called before

args = parser.parse_args()

, how does

python run_experiment --data_class EMNISTLines --max_length 19 --max_overlap 4

not fail? Doesn't the parser lack the arguments max_length and max_overlap, because only MNIST.add_to_argparse, and not EMNISTLines.add_to_argparse, has been called?

Please help me understand...

qAp commented 2 years ago

ok, _setup_parser doesn't work as expected if called directly inside an interactive environment like a notebook, but called inside a script it's fine.