I am testing a simple model with the main to serving it . I am in colab environment.
executing the code
import numpy as np
from tensorflow import keras
model=tf.keras.Sequential([keras.layers.Dense(units=1,input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')
xs=np.array([-1.0,0.0,1.0,2.0,3.0,4.0],dtype=float)
ys=np.array([-3.0,-1.0,1.0,3.0,5.0,7.0],dtype=float)
model.fit(xs,ys,epochs=500,verbose=2)
tf.saved_model.simple_save(
keras.backend.get_session(),
export_path,
inputs={'input_image': model.input},
outputs={t.name:t for t in model.outputs})
I obtain the following error that I don't know how to fix:
<ipython-input-19-634675006b49> in <module>()
----> 1 tf.saved_model.simple_save(
2 keras.backend.get_session(),
3 export_path,
4 inputs={'input_image': model.input},
5 outputs={t.name:t for t in model.outputs})
AttributeError: module 'tensorflow._api.v2.saved_model' has no attribute 'simple_save'```
question from:
https://stackoverflow.com/questions/65952161/error-in-trying-to-save-a-tensorflow-model 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…