1# Copyright 2019 The TensorFlow Authors. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================== 15"""Constants for Keras SavedModel serialization.""" 16 17# Namespace used to store all attributes added during serialization. 18# e.g. the list of layers can be accessed using `loaded.keras_api.layers`, in an 19# object loaded from `tf.saved_model.load()`. 20KERAS_ATTR = 'keras_api' 21 22# Keys for the serialization cache. 23# Maps to the keras serialization dict {Layer --> SerializedAttributes object} 24KERAS_CACHE_KEY = 'keras_serialized_attributes' 25 26 27# Name of Keras metadata file stored in the SavedModel. 28SAVED_METADATA_PATH = 'keras_metadata.pb' 29 30# Names of SavedObject Keras identifiers. 31INPUT_LAYER_IDENTIFIER = '_tf_keras_input_layer' 32LAYER_IDENTIFIER = '_tf_keras_layer' 33METRIC_IDENTIFIER = '_tf_keras_metric' 34MODEL_IDENTIFIER = '_tf_keras_model' 35NETWORK_IDENTIFIER = '_tf_keras_network' 36RNN_LAYER_IDENTIFIER = '_tf_keras_rnn_layer' 37SEQUENTIAL_IDENTIFIER = '_tf_keras_sequential' 38 39KERAS_OBJECT_IDENTIFIERS = ( 40 INPUT_LAYER_IDENTIFIER, 41 LAYER_IDENTIFIER, 42 METRIC_IDENTIFIER, 43 MODEL_IDENTIFIER, 44 NETWORK_IDENTIFIER, 45 RNN_LAYER_IDENTIFIER, 46 SEQUENTIAL_IDENTIFIER, 47) 48