title: AttributeError: 'Tensor' object has no attribute '_keras_shape' when creating a model in keras
body: <p>When i define a model in keras an error is shown as follows
  AttributeError: 'Tensor' object has no attribute '_keras_shape'</p>
  
  <p>the code producing the error is </p>
  
  <pre><code>vocab_size = 10000
  MAX_SEQUENCE_LENGTH = 256
  sequence_input = keras.layers.Input(shape=(MAX_SEQUENCE_LENGTH,), dtype='int32')
  embedding=keras.layers.Embedding(vocab_size, 16, input_length  = MAX_SEQUENCE_LENGTH)(sequence_input)
  x=keras.layers.GlobalAveragePooling1D()(embedding)
  x=keras.layers.Dense(16, activation=tf.nn.relu)(x)
  
  preds = keras.layers.Dense(1, activation=tf.nn.sigmoid)(x)
  
  model = Model(inputs=sequence_input, outputs=preds)
  model.compile(optimizer=tf.train.AdamOptimizer(),
            loss='binary_crossentropy',
            metrics=['accuracy'])
  </code></pre>
  
  <p>complete error message is shown below</p>
  
  <pre><code>AttributeError                            Traceback (most recent call last)
  &lt;ipython-input-5-1c6ea41c38e1&gt; in &lt;module&gt;()
        1 from keras.models import Model
  ----&gt; 2 model = Model(inputs=sequence_input, outputs=preds)
        3 model.compile(optimizer=tf.train.AdamOptimizer(),
        4               loss='binary_crossentropy',
        5               metrics=['accuracy'])
  
  ~/Datacube/datacube_env/lib/python3.5/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
       89                 warnings.warn('Update your `' + object_name +
       90                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
  ---&gt; 91             return func(*args, **kwargs)
       92         wrapper._original_function = func
       93         return wrapper
  
  ~/Datacube/datacube_env/lib/python3.5/site-packages/keras/engine/network.py in __init__(self, *args, **kwargs)
       89                 'inputs' in kwargs and 'outputs' in kwargs):
       90             # Graph network
  ---&gt; 91             self._init_graph_network(*args, **kwargs)
       92         else:
       93             # Subclassed network
  
  ~/Datacube/datacube_env/lib/python3.5/site-packages/keras/engine/network.py in _init_graph_network(self, inputs, outputs, name)
      249              input_masks=[None for _ in self.inputs],
      250              output_masks=[None for _ in self.outputs],
  --&gt; 251              input_shapes=[x._keras_shape for x in self.inputs],
      252              output_shapes=[x._keras_shape for x in self.outputs])
      253 
  
  ~/Datacube/datacube_env/lib/python3.5/site-packages/keras/engine/network.py in &lt;listcomp&gt;(.0)
      249              input_masks=[None for _ in self.inputs],
      250              output_masks=[None for _ in self.outputs],
  --&gt; 251              input_shapes=[x._keras_shape for x in self.inputs],
      252              output_shapes=[x._keras_shape for x in self.outputs])
      253 
  
  AttributeError: 'Tensor' object has no attribute '_keras_shape'
  </code></pre>
  
  <p>can anyone tell me how to solve this</p>