【发布时间】:2021-04-25 04:10:20
【问题描述】:
我有一些包含 tensorflow 标志的 tensorflow 代码,如下所示:
from tensorflow.python.platform import flags
FLAGS = flags.FLAGS
## Logging, saving, and testing options
flags.DEFINE_bool('log', True, 'if false, do not log summaries, for debugging code.')
flags.DEFINE_string('logdir', 'trained_mdl/', 'directory for summaries and checkpoints.')
flags.DEFINE_bool('resume', True, 'resume training if there is a model available')
flags.DEFINE_bool('train', False, 'True to train, False to test.')
flags.DEFINE_integer('test_iter', -1, 'iteration to load model (-1 for latest model)')
flags.DEFINE_bool('test_set', True, 'Set to true to test on the the test set, False for the validation set.')
flags.DEFINE_integer('train_update_batch_size', -1, 'number of examples used for gradient update during training (use if you want to test with a different number).')
flags.DEFINE_float('train_update_lr', -1, 'value of inner gradient step step during training. (use if you want to test with a different value)') # 0.1 for omniglot
我想运行几次,为此,我编写了一个 bash 脚本,如下所示:
#!/usr/bin/env bash
python main.py
--meta_batch_size 8
--train True
--test_set False
> main1_train.txt
但它重新开始然后永远不会执行。带有张量流标志的 bash 根本不起作用吗?如果是这样,那么我没有其他选择可以使用argparse 而不是FLAGS?
更新 1
我收到以下错误:
run_main1.sh: line 5: --meta_batch_size: command not found
run_main1.sh: line 6: --train: command not found
run_main1.sh: line 7: --test_set: command not found
【问题讨论】:
-
您可以通过shebang
#! /bin/bash -x获取更多调试数据。错误输出是什么? -
@Bayou 不幸的是,bash 窗口在我看到错误之前关闭。它也不会打印到我将输出定向到的输出文件中
-
@Bayou 我已将错误放在更新的问题中
标签: python bash tensorflow