title: Keras Custom Layer : 'Node' object has no attribute 'output_masks'
body: <p>I am trying to build a custom layer with Keras with Tensorflow backend in order to process images.</p>
  
  <p>The process fails when using Keras but works with tensorflow (partially).</p>
  
  <p>To understand better the issue I implemented an Identity layer and had the same issue : </p>
  
  <blockquote>
    <p>'Node' object has no attribute 'output_masks'</p>
  </blockquote>
  
  <p>Here is my code :</p>
  
  <pre><code>from tensorflow.python.keras.layers import *
  from tensorflow.python.keras import Model
  from tensorflow.python.keras import  optimizers
  
  import cv2
  
  from keras.engine.topology import Layer # This Layer does not work
  
  #
  # USE KERAS IMPLEMENTED INTO TENSORFLOW TO MAKE IT WORK
  #
  
  #from tensorflow.python.keras._impl.keras.engine.base_layer import Layer
  
  import numpy as np
  
  
  class Identity(Layer):
  
      def __init__(self, **kwargs):
  
          super(Identity, self).__init__(**kwargs)
  
      def build(self, input_shape):
  
          super(Identity, self).build(input_shape)  # Be sure to call this somewhere!
  
  
      def call(self, x):
  
          return x
  
  
      def compute_output_shape(self, input_shape):
  
          return tuple(input_shape)
  
  
  
  
  height = 12
  width = 18
  channels = 3
  
  image_original = cv2.imread("./predict_base.png")
  input_data = np.zeros((2, 12, 18, 3))
  input_data[0] = image_original
  input_data[1] = image_original
  
  input_shape = (height, width, channels)
  
  input = Input(shape=input_shape)
  output = Identity()(input)
  
  # add the model on top of the convolutional base
  model = Model(inputs=input, outputs=output)
  
  adam = optimizers.Adam()
  model.compile(loss='mean_squared_error', optimizer=adam)
  
  model.summary()
  image = model.predict(input_data)
  
  cv2.imshow("result", image[0])
  cv2.waitKey(0)
  </code></pre>
  
  <p>Whereas a more complex layer works in using directly tensorflow, it fails to compute the output shape correctly.</p>
  
  <p>If I introduce an error in the output shape computation such as :</p>
  
  <pre><code>def compute_output_shape(self, input_shape):
      output_shape = []
      output_shape[0] = input_shape[0]
      output_shape[1] = input_shape[1]
      output_shape[2] = input_shape[2]
      output_shape[3] = 4               #Here is the error I added
  
      return tuple(output_shape)
  </code></pre>
  
  <p>The output shape is still the same, tensorflow does not compute the output correctly. </p>
  
  <p>Do you have any idea how to fix this ?</p>
  
  <p>Many thanks.</p>