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

error to parse FLAGS #127

Open
dingguijin opened this issue Dec 26, 2017 · 13 comments
Open

error to parse FLAGS #127

dingguijin opened this issue Dec 26, 2017 · 13 comments

Comments

@dingguijin
Copy link

python 2.7
tensorflow 1.4.0

FLAGS._parse_flags() not support any longer use FLAGS(sys.argv) instead. (call the python object)

@goongong
Copy link

same question

@imprasshant
Copy link

@dingguijin
Running the same script by changing to FLAGS(sys.argv) only is not working ,giving me this error
plz help..In my case it is working good in tensorflow(1.4.) but not in tensorflow(1.5.0).

ALLOW_SOFT_PLACEMENT=<absl.flags._flag.BooleanFlag object at 0x8f6a910>
BATCH_SIZE=<absl.flags._flag.Flag object at 0x8f6a6d0>
CHECKPOINT_EVERY=<absl.flags._flag.Flag object at 0x8f6a850>
DEV_SAMPLE_PERCENTAGE=<absl.flags._flag.Flag object at 0x8f6a210>
DROPOUT_KEEP_PROB=<absl.flags._flag.Flag object at 0x8f6a5d0>
EMBEDDING_DIM=<absl.flags._flag.Flag object at 0x8f6a450>
EVALUATE_EVERY=<absl.flags._flag.Flag object at 0x8f6a7d0>
FILTER_SIZES=<absl.flags._flag.Flag object at 0x8f6a4d0>
L2_REG_LAMBDA=<absl.flags._flag.Flag object at 0x8f6a650>
LOG_DEVICE_PLACEMENT=<absl.flags._flag.BooleanFlag object at 0x8f6a950>
NUM-FILTERS=<absl.flags._flag.Flag object at 0x8f6a550>
NUM_CHECKPOINTS=<absl.flags._flag.Flag object at 0x8f6a8d0>
NUM_EPOCHS=<absl.flags._flag.Flag object at 0x8f6a750>

2018-02-07 14:49:07.184974: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
Traceback (most recent call last):
File "train.py", line 89, in
num_filters=FLAGS.num_filters,
File "/usr/lib/python2.7/site-packages/tensorflow/python/platform/flags.py", line 85, in getattr
return wrapped.getattr(name)
File "/usr/lib/python2.7/site-packages/absl/flags/_flagvalues.py", line 470, in getattr
raise AttributeError(name)
AttributeError: num_filters

@alviandk
Copy link

alviandk commented Feb 7, 2018

the code did not updated since a year ago, use tensorflow 1.0.0 (pip install tensorflow==1.0.0) solve the problem "FLAGS._parse_flags() not support any longer use FLAGS(sys.argv) instead. (call the python object)". don't forget to use python3 because it is stated on the readme.

@coffeedjimmy
Copy link

@imprasshant

I've encountered same problem. That's because original FLAGS is replaced with abseil's one.

If you want to use original one, you need to use tensorflow <=1.4.

Please check these links.

tensorflow 1.4

tensorflow 1.5

@imprasshant
Copy link

@coffeedjimmy thanks . yeah i m also trying to fix that problem so that it can be run on tensorflow>=1.4.
I will post once solved.

@rickyhai11
Copy link

I still encountered this issue when running with tensorflow 1.5. Someone could help to overcome this issue on tensorflow 1.5?
Thanks

@coffeedjimmy
Copy link

coffeedjimmy commented Apr 19, 2018

@rickyhai11

You can simply use argparse module in Python instead of tf.FLAGS.

Here is the reference code for better understanding.

@POMCP
Copy link

POMCP commented May 3, 2018

The problem seems to be machine dependant, I am using tensorflow 1.8. I did encounter the problem with FLAGS but using FLAGS(sys.argv) solved the problem for me. I am using a MacBook Pro: macOS High Sierra. Try running the code in a virtual environment. python3 -m venv virtual_env_name. Install tensorflow and then change the FLAGS(sys.argv).

dennybritz added a commit that referenced this issue May 11, 2018
@Nadedic
Copy link

Nadedic commented Jul 9, 2018

@coffeedjimmy could you elaborate more in the code please?!

@bileki
Copy link

bileki commented Aug 15, 2018

parser = argparse.ArgumentParser()
#Data Parameters
parser.add_argument('--positive_data_file', type=str, default='./data/rt-polaritydata/rt-polarity.pos',
help='Data source for the positive data.')
parser.add_argument('--negative_data_file', type=str, default='./data/rt-polaritydata/rt-polarity.neg',
help='Data source for the positive data.')

#Eval Parameters
parser.add_argument('--batch_size', type=int, default=64,
help='Batch Size (default: 64).')
parser.add_argument('--checkpoint_dir', type=str, default=None,
help='Checkpoint directory from training run.')
parser.add_argument('--eval_train', type=bool, default=False,
help='Evaluate on all training data.')

#Misc Parameters
parser.add_argument('--allow_soft_placement', type=bool, default=True,
help='Allow device soft device placement.')
parser.add_argument('--log_device_placement', type=bool, default=False,
help='Log placement of ops on devices.')

FLAGS = parser.parse_args()

@Glitchfix
Copy link

In one of my projects FLAGS(sys.argv) seemed to fix the problem.

@yalidu
Copy link

yalidu commented Sep 14, 2018

In one of my projects FLAGS(sys.argv) seemed to fix the problem.

This solution works for me! I'm using tensorflow=1.9.

@tusonggao
Copy link

tusonggao commented Nov 15, 2018

python 3.6
tensorflow 1.5.0

encountered an error AttributeError: _parse_flags in eval.py.
solution worked for me: #165

should add a True value when running the eval command.
./eval.py --eval_train True --checkpoint_dir="./runs/1459637919/checkpoints/"

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