title: How to save keras recommenderNet model?
body: <p>After building the model from Embedding RecommenderNet model, how to save it, link to the doc is <a href="https://keras.io/examples/structured_data/collaborative_filtering_movielens/" rel="nofollow noreferrer">https://keras.io/examples/structured_data/collaborative_filtering_movielens/</a></p>
  <pre><code>class RecommenderNet(keras.Model):
      def __init__(self, num_users, num_movies, embedding_size, **kwargs):
          super(RecommenderNet, self).__init__(**kwargs)
          self.num_users = num_users
          self.num_movies = num_movies
          self.embedding_size = embedding_size
          self.user_embedding = layers.Embedding(
              num_users,
              embedding_size,
              embeddings_initializer=&quot;he_normal&quot;,
              embeddings_regularizer=keras.regularizers.l2(1e-6),
          )
          self.user_bias = layers.Embedding(num_users, 1)
          self.movie_embedding = layers.Embedding(
              num_movies,
              embedding_size,
              embeddings_initializer=&quot;he_normal&quot;,
              embeddings_regularizer=keras.regularizers.l2(1e-6),
          )
          self.movie_bias = layers.Embedding(num_movies, 1)
  
      def call(self, inputs):
          user_vector = self.user_embedding(inputs[:, 0])
          user_bias = self.user_bias(inputs[:, 0])
          movie_vector = self.movie_embedding(inputs[:, 1])
          movie_bias = self.movie_bias(inputs[:, 1])
          dot_user_movie = tf.tensordot(user_vector, movie_vector, 2)
          # Add all the components (including bias)
          x = dot_user_movie + user_bias + movie_bias
          # The sigmoid activation forces the rating to between 0 and 1
          return tf.nn.sigmoid(x)
  
  
  model = RecommenderNet(num_users, num_movies, EMBEDDING_SIZE)
  model.compile(
      loss=tf.keras.losses.BinaryCrossentropy(), optimizer=keras.optimizers.Adam(lr=0.001)
  )
  history = model.fit(
      x=x_train,
      y=y_train,
      batch_size=64,
      epochs=5,
      verbose=1,
      validation_data=(x_val, y_val),
  )
  </code></pre>
  <p>tried these</p>
  <pre><code>model.save('model.h5py')
  tf.keras.models.save_model(model, overwrite=True, include_optimizer=True, save_format='h5')
  </code></pre>
  <p>Both throws</p>
  <pre><code>NotImplementedError: Saving the model to HDF5 format requires the model to be a Functional model or 
  a Sequential model.It does not work for subclassed models, because such models are defined via the body of 
  a Python method, which isn't safely serializable. Consider saving to the Tensorflow SavedModel 
  format (by setting save_format=&quot;tf&quot;) or using `save_weights`.
  </code></pre>
  <p>model type is <strong>main</strong>.RecommenderNet</p>