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

absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'cfg'. Did you mean: cfg_path ? #20

Open
1993cathyzhao1993 opened this issue Jan 20, 2021 · 1 comment

Comments

@1993cathyzhao1993
Copy link

I follow ur instrumentation,but when I wanna train.
absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'cfg'. Did you mean: cfg_path ?

This problem troubled me.
How to solve this problem.hope to get ur answer.
thanks

@Zhuosd
Copy link

Zhuosd commented Mar 15, 2022

I know how to deal with this problem!

My code is shown here:

flags = tf.compat.v1.app.flags

if not os.path.exists(cfg_path):
    raise RuntimeError(
        "[!] Configuration path {} does not exist.".format(cfg_path))
if os.path.isdir(cfg_path):
    cfg_path = os.path.join(cfg_path, 'cfg.yml')
    with open(cfg_path, 'r') as f:
        cfg = yaml.safe_load(f)
else:
    with open(cfg_path, 'r') as f:
        loaded_cfg = yaml.safe_load(f)
    base_dir = os.path.dirname(cfg_path)
    with open(os.path.join(base_dir, 'default.yml'), 'r') as f:
        cfg = yaml.safe_load(f)

    cfg.update(loaded_cfg)

with open(os.path.join('experiments/cfgs', 'key_doc.yml')) as f:
    docs = yaml.safe_load(f)
    
flags.DEFINE_string('cfg_path', cfg_path, 'config path.')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants