'making a layer or a model inside a a tf.compat.v1.Graph invalidates all layers/models you previously made outside of the graph

ValueError: Your Layer or Model is in an invalid state. This can happen for the following cases:

  1. You might be interleaving estimator/non-estimator models or interleaving models/layers made in tf.compat.v1.Graph.as_default() with models/layers created outside of it. Converting a model to an estimator (via model_to_estimator) invalidates all models/layers made before the conversion (even if they were not the model converted to an estimator). Similarly, making a layer or a model inside a a tf.compat.v1.Graph invalidates all layers/models you previously made outside of the graph.
  2. You might be using a custom keras layer implementation with custom init which didn't call super().init. Please check the implementation of <class 'keras.engine.functional.Functional'> and its bases.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source