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 17from __future__ import absolute_import 18from __future__ import division 19from __future__ import print_function 20 21# Namespace used to store all attributes added during serialization. 22# e.g. the list of layers can be accessed using `loaded.keras_api.layers`, in an 23# object loaded from `tf.saved_model.load()`. 24KERAS_ATTR = 'keras_api' 25 26# Keys for the serialization cache. 27# Maps to the keras serialization dict {Layer --> SerializedAttributes object} 28KERAS_CACHE_KEY = 'keras_serialized_attributes' 29 30 31# Name of Keras metadata file stored in the SavedModel. 32SAVED_METADATA_PATH = 'keras_metadata.pb' 33 34# Names of SavedObject Keras identifiers. 35INPUT_LAYER_IDENTIFIER = '_tf_keras_input_layer' 36LAYER_IDENTIFIER = '_tf_keras_layer' 37METRIC_IDENTIFIER = '_tf_keras_metric' 38MODEL_IDENTIFIER = '_tf_keras_model' 39NETWORK_IDENTIFIER = '_tf_keras_network' 40RNN_LAYER_IDENTIFIER = '_tf_keras_rnn_layer' 41SEQUENTIAL_IDENTIFIER = '_tf_keras_sequential' 42 43KERAS_OBJECT_IDENTIFIERS = ( 44 INPUT_LAYER_IDENTIFIER, 45 LAYER_IDENTIFIER, 46 METRIC_IDENTIFIER, 47 MODEL_IDENTIFIER, 48 NETWORK_IDENTIFIER, 49 RNN_LAYER_IDENTIFIER, 50 SEQUENTIAL_IDENTIFIER, 51) 52