Siddharth Rawat
Siddharth Rawat

Reputation: 121

cannot import name 'Input' from 'tensorflow.keras.models'

I am running TensorFlow 2.0 GPU (CUDA), Keras, & Python 3.7 in Windows 10. i am getting the following error:

ImportError                               Traceback (most recent call last)
<ipython-input-8-2fd313bcdf5e> in <module>
      9 from tensorflow.keras.initializers import RandomNormal
     10 from tensorflow.keras.models import Model
---> 11 from tensorflow.keras.models import Input
     12 from tensorflow.keras.layers import Conv2D
     13 from tensorflow.keras.layers import Conv2DTranspose

ImportError: cannot import name 'Input' from 'tensorflow.keras.models' (C:\Users\Syd_R\anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\api\_v2\keras\models\__init__.py)

Upvotes: 7

Views: 27031

Answers (3)

niek tuytel
niek tuytel

Reputation: 1179

They change location in newer version:
from tensorflow.keras import Input

Upvotes: 0

rsk
rsk

Reputation: 61

This works for me:

from tensorflow.python.keras.models import Input

Upvotes: 4

pecey
pecey

Reputation: 681

It should be from tensorflow.keras.layers import Input.

Upvotes: 8

Related Questions