Я хочу сохранить глубоко корректную модель в Tensorflow Serving, но я получаю ошибку
from deepcorrect import DeepCorrect
model = DeepCorrect('deeppunct_params_en', 'deeppunct_checkpoint_wikipedia')
model.deepcorrect_model[0]
import tempfile
import os
import tensorflow as tf
MODEL_DIR = tempfile.gettempdir()
version = 1
export_path = os.path.join(MODEL_DIR, str(version))
print('export_path = {}\n'.format(export_path))
tf.keras.models.save_model(
model.deepcorrect_model[0],
export_path,
overwrite=True,
include_optimizer=True,
save_format=None,
signatures=None
)
print('\nSaved model:')
!ls -l {export_path}
Это моя ошибка:
export_path = /tmp/1
/usr/local/lib/python3.6/dist-packages/keras/engine/network.py:883: UserWarning: Layer lstm_2 was passed non-serializable keyword arguments: {'initial_state': [<tf.Tensor 'strided_slice:0' shape=(?, 256) dtype=float32>, <tf.Tensor 'strided_slice:0' shape=(?, 256) dtype=float32>]}. They will not be included in the serialized model (and thus will be missing at deserialization time).
'. They will not be included '
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-7837d3d06154> in <module>()
15 include_optimizer=True,
16 save_format=None,
---> 17 signatures=None
18 )
19
2 frames
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/saving_utils.py in model_metadata(model, include_optimizer, require_config)
180 'loss': model.loss,
181 # pylint: disable=protected-access
--> 182 'metrics': model._compile_metrics,
183 'weighted_metrics': model._compile_weighted_metrics,
184 # pylint: enable=protected-access
AttributeError: 'Model' object has no attribute '_compile_metrics'
Это глубоко правильное репо: https://github.com/bedapudi6788/deepcorrect
Как сохранить модель в режиме обслуживания Tensorflow?