Do you have already tried with:

  

      github.com/tensorflow/tensorflow
  

  
    
  
	  
  

  
    
      `tf.keras.Model.save` does not support subclassed model when saving model as SavedModel format 159
    

    
      
        opened 
        
          
        
        Jul 26, 2019
      
      

        
          closed 
        
          
        
        Aug 10, 2019
      
        

      
        
          
          zakizhou
        
      
    

    
        TF 2.0
        comp:keras
        type:support
    
  


  
    <em>Please make sure that this is a bug. As per our [GitHub Policy](https://gith…ub.com/tensorflow/tensorflow/blob/master/ISSUES.md), we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template</em>

**System information**
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): NA
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Mac
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: None
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below): 2.0.0-dev20190724
- Python version: 3.6
- Bazel version (if compiling from source): None
- GCC/Compiler version (if compiling from source): None
- CUDA/cuDNN version: None
- GPU model and memory: None

You can collect some of this information using our environment capture
[script](https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh)
You can also obtain the TensorFlow version with: 1. TF 1.0: `python -c "import
tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"` 2. TF 2.0: `python -c
"import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"`

**Describe the current behavior**
`tf.keras.Model.save`  **DOES NOT** support subclassed model when saving model as SavedModel format
**Describe the expected behavior**
`tf.keras.Model.save` **SHOULD** support subclassed model when saving model as SavedModel format
**Code to reproduce the issue**
```
import tensorflow as tf


class Model(tf.keras.Model):
    def __init__(self):
        super(Model, self).__init__()
        self.d = tf.keras.layers.Dense(2)

    @tf.function
    def call(self, x, training=True, mask=None):
        return self.d(x)


model = Model()
model(tf.random.normal((2, 3)))
# next line raises errors
model.save("save/model", save_format="tf")
```
Provide a reproducible test case that is the bare minimum necessary to generate the problem.

**Other info / logs**
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.