title: Tensorflow 1.14+ Serialize Subclassed Keras Layers?
body: <p>I've gone through and re-re-re-read the Tensorflow Keras docs, e.g.</p>
  
  <ul>
  <li><a href="https://www.tensorflow.org/beta/guide/keras/functional" rel="nofollow noreferrer">https://www.tensorflow.org/beta/guide/keras/functional</a></li>
  <li><a href="https://www.tensorflow.org/beta/guide/keras/custom_layers_and_models" rel="nofollow noreferrer">https://www.tensorflow.org/beta/guide/keras/custom_layers_and_models</a></li>
  </ul>
  
  <p>I have a simple subclassed layer:</p>
  
  <pre><code>class SimpleLayer(tf.keras.layers.Layer):
      def __init__(self, filters, kernel_size, **kwargs):
          super(SimpleLayer, self).__init__()
          self.filters = filters
          self.kernel_size = kernel_size
          self.c1 = tf.keras.layers.Conv1D(filters, kernel_size, padding='same', activation='relu')
          self.c2 = tf.keras.layers.Conv1D(filters, kernel_size, padding='same')
  
      def call(self, inputs):
          x = inputs
          x = self.c1(x)
          x = self.c2(x)
          return x
  
      def get_config(self):
          # config = super(tf.keras.layers.Layer, self).get_config()
          config = {}
          config.update({
              'filters': self.filters,
              'kernel_size': self.kernel_size,
          })
          return config
  </code></pre>
  
  <p>and then have a functional model:</p>
  
  <pre class="lang-py prettyprint-override"><code>
  x = tf.keras.Inputs(...)
  
  # some keras layers
  y = tf.keras.layers... (x)
  
  # my keras layer
  y = SimpleLayer(...)(y)
  
  # some keras layers
  y = tf.keras.layers... (y)
  y = tf.keras.layers.Dense(1)(y)
  
  model = tf.keras.Model(inputs=x, outputs=y)
  model.compile(...)
  
  model.fit(...)
  
  model.save('model.h5')
  </code></pre>
  
  <p>and figure then I could load the model as:</p>
  
  <pre class="lang-py prettyprint-override"><code>tf.keras.models.load_model('model.h5')
  </code></pre>
  
  <p>but I get:</p>
  
  <pre><code>ValueError: Unknown layer: SimpleLayer
  </code></pre>
  
  <p>from the <a href="https://www.tensorflow.org/beta/guide/keras/custom_layers_and_models#you_can_optionally_enable_serialization_on_your_layers" rel="nofollow noreferrer">docs</a>:</p>
  
  <blockquote>
    <p>If you need your custom layers to be serializable as part of a Functional model, you can optionally implement a get_config method</p>
  </blockquote>
  
  <p>which I have. </p>
  
  <p>What am I doing wrong?</p>