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

Tensorflow Flag #2

Open
rkarn opened this issue Jun 23, 2018 · 2 comments
Open

Tensorflow Flag #2

rkarn opened this issue Jun 23, 2018 · 2 comments

Comments

@rkarn
Copy link

rkarn commented Jun 23, 2018

I got this error:
from ._conv import register_converters as _register_converters
Traceback (most recent call last):
File "DEN_run.py", line 13, in
flags.DEFINE_integer("dims", [784, 312, 128, 10], "Dimensions about layers including output")
File "/Users/rupesh.karn/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/flags.py", line 58, in wrapper
return original_function(*args, **kwargs)
File "/Users/rupesh.karn/anaconda2/lib/python2.7/site-packages/absl/flags/_defines.py", line 315, in DEFINE_integer
DEFINE(parser, name, default, help, flag_values, serializer, **args)
File "/Users/rupesh.karn/anaconda2/lib/python2.7/site-packages/absl/flags/_defines.py", line 81, in DEFINE
DEFINE_flag(_flag.Flag(parser, serializer, name, default, help, **args),
File "/Users/rupesh.karn/anaconda2/lib/python2.7/site-packages/absl/flags/_flag.py", line 107, in init
self._set_default(default)
File "/Users/rupesh.karn/anaconda2/lib/python2.7/site-packages/absl/flags/_flag.py", line 196, in _set_default
self.default = self._parse(value)
File "/Users/rupesh.karn/anaconda2/lib/python2.7/site-packages/absl/flags/_flag.py", line 169, in _parse
'flag --%s=%s: %s' % (self.name, argument, e))
absl.flags._exceptions.IllegalFlagValueError: flag --dims=[784, 312, 128, 10]: Expect argument to be a string or int, found <type 'list'>

The issue is in the flag statement in DEN_run.py.
flags.DEFINE_integer("dims", [784, 312, 128, 10], "Dimensions about layers including output")

A list is passed instead of int.

Solution:
Divide the list into integer in DEN_run.py as :
flags.DEFINE_integer("dims0", 784, "Dimensions about input layer")
flags.DEFINE_integer("dims1", 312, "Dimensions about 1st layer")
flags.DEFINE_integer("dims2", 128, "Dimensions about 2nd layer")
flags.DEFINE_integer("dims3", 10, "Dimensions about output layer")

Then, modify in DEN.py for line "self.dims = config.dims" as :
self.dims0 = config.dims0
self.dims1 = config.dims1
self.dims2 = config.dims2
self.dims3 = config.dims3
nn_shape = [self.dims0, self.dims1, self.dims2, self.dims3]
self.dims = nn_shape

To run the code in Jupyter notebook, add these lines before creating the model from DEN class:

remaining_args = FLAGS([sys.argv[0]] + [flag for flag in sys.argv if flag.startswith("--")])
assert(remaining_args == [sys.argv[0]])

yhgon added a commit to yhgon/DEN that referenced this issue Feb 6, 2019
yhgon added a commit to yhgon/DEN that referenced this issue Feb 6, 2019
@yanbin-wang
Copy link

I have a this problem. I do not understand what is mean the command “updata DEN.py”. It not work for me

@scakc
Copy link

scakc commented Sep 13, 2019

or simply replace the line
flags.DEFINE_integer("dims", [784, 312, 128, 10], "Dimensions about layers including output")
with :
flags.DEFINE_list("dims", [784, 312, 128, 10], "Dimensions about layers including output")

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

3 participants