stecklin
stecklin

Reputation: 131

Load TensorFlow FLAGS from file (TF version > 1.4)

I would like to store FLAGS (tf.app.flags.FLAGS) in a file and reload them later. Until TensorFlow 1.4, I used this code for reloading:

with open(config_file, 'r') as f:
     config = json.load(f)
     FLAGS.__flags.update(config)

From TensorFlow 1.5, the underlying implementation of FLAGS changed. Does anybody know a way to update the FLAGS with values stored in a file?

Upvotes: 0

Views: 776

Answers (1)

Weidong Xu
Weidong Xu

Reputation: 31

Try:

with open(config_file, 'r') as f:
    config = json.load(f)
    for name, value in config.items():
        FLAGS.__flags[name].value = value

Upvotes: 3

Related Questions