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

ValueError: The first layer in a Sequential model must get an input_shape argument. #4104

Closed
ysong-2018 opened this issue Apr 27, 2018 · 9 comments
Assignees

Comments

@ysong-2018
Copy link

When running the officials/mnist/mnist.py there is an error message:

Traceback (most recent call last):
File "mnist.py", line 261, in
main(argv=sys.argv)
File "mnist.py", line 225, in main
mnist_classifier.train(input_fn=train_input_fn, hooks=train_hooks)
File "/Users/yangsong/tensorflow/lib/python3.5/site-packages/tensorflow/python/estimator/estimator.py", line 355, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "/Users/yangsong/tensorflow/lib/python3.5/site-packages/tensorflow/python/estimator/estimator.py", line 824, in _train_model
features, labels, model_fn_lib.ModeKeys.TRAIN, self.config)
File "/Users/yangsong/tensorflow/lib/python3.5/site-packages/tensorflow/python/estimator/estimator.py", line 805, in _call_model_fn
model_fn_results = self._model_fn(features=features, **kwargs)
File "mnist.py", line 89, in model_fn
model = create_model(params['data_format'])
File "mnist.py", line 83, in create_model
l.Dense(10)
File "/Users/yangsong/tensorflow/lib/python3.5/site-packages/tensorflow/python/keras/_impl/keras/engine/sequential.py", line 120, in init
self.add(layer)
File "/Users/yangsong/tensorflow/lib/python3.5/site-packages/tensorflow/python/keras/_impl/keras/engine/sequential.py", line 163, in add
raise ValueError('The first layer in a '
ValueError: The first layer in a Sequential model must get an input_shape argument.

Please go to Stack Overflow for help and support:

http://stackoverflow.com/questions/tagged/tensorflow

Also, please understand that many of the models included in this repository are experimental and research-style code. If you open a GitHub issue, here is our policy:

  1. It must be a bug, a feature request, or a significant problem with documentation (for small docs fixes please send a PR instead).
  2. The form below must be filled out.

Here's why we have that policy: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.


System information

  • What is the top-level directory of the model you are using:
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • TensorFlow installed from (source or binary):
  • TensorFlow version (use command below):
  • Bazel version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:
  • Exact command to reproduce:

You can collect some of this information using our environment capture script:

https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh

You can obtain the TensorFlow version with

python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"

Describe the problem

Describe the problem clearly here. Be sure to convey here why it's a bug in TensorFlow or a feature request.

Source code / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem.

@k-w-w
Copy link
Contributor

k-w-w commented Apr 27, 2018

Hmmm I'm not running into this error. What version of tensorflow are you running?

@k-w-w k-w-w added the stat:awaiting response Waiting on input from the contributor label Apr 27, 2018
@ysong-2018
Copy link
Author

I checked my tensorflow version and it is 1.4.0. I am running this on a macbook os system and have already set the paths and dependencies.

@k-w-w
Copy link
Contributor

k-w-w commented Apr 27, 2018

In that case, please check out the r1.4.0 branch or release. The master version is updated to work with the Tensorflow nightly build.

@ysong-2018
Copy link
Author

Thank you so much, that solved the problem

xueeinstein added a commit to xueeinstein/models that referenced this issue May 2, 2018
* 'master' of https://github.com/tensorflow/models: (404 commits)
  official/mnist: Updates with the release of TensorFlow 1.8.
  Internal changes to slim and object detection (tensorflow#4100)
  catch cpuinfo ImportError (tensorflow#4138)
  [samples/core/get_starter/eager]: Update with API simplifications in 1.8
  Add vincentvanhoucke as owner for research/marco
  Add marco subdirectory to README.md
  Create request.json
  Create jpeg2json.py
  Fix width / height.
  Create README.md
  Add new import paths to mnist_tpu.py (tensorflow#4133)
  fix model call (tensorflow#4132)
  Remove useless fields in resnet_model (tensorflow#4110)
  official/mnist: Add input_shape parameter to initial layer (tensorflow#4104) (tensorflow#4118)
  Increase minimum TF version for DEFINE_enum and rename variable mappings for change to RNN variable names. (tensorflow#4123)
  fix import errors
  Minor update the resnet runloop. (tensorflow#4113)
  Two new plot-generating scripts and changes in support of the ICLR poster. (tensorflow#4092)
  Add export savedmodel to wide_deep (tensorflow#4041)
  Fix 2 typos
  ...
@leccyril
Copy link

hi, i have this problem with version 1.8

@ysong-2018 ysong-2018 reopened this Jun 2, 2018
@eantaev
Copy link
Contributor

eantaev commented Jun 2, 2018

Fix is merged into master and later to r1.9.0.
Implementation in r1.8.* differs from master and it is not fixed.
So, @leccyril you might switch to master or r1.9.0

@tensorflowbutler tensorflowbutler removed the stat:awaiting response Waiting on input from the contributor label Jun 2, 2018
@k-w-w
Copy link
Contributor

k-w-w commented Jun 14, 2018

@leccyril Have you tried switching to r1.9.0 or master, and has it worked?

@vincentmader
Copy link

I also get this problem, running tensorflow 1.5. on macOS Mojave

@tensorflowbutler
Copy link
Member

Hi There,
We are checking to see if you still need help on this, as this seems to be considerably old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing.
If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.

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

6 participants