| 12345678910111213141516171819202122232425262728293031 |
- # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- #
- # author: Tomasz Grel ([email protected])
- from collections import OrderedDict
- def create_inputs_dict(numerical_features, categorical_features):
- # Passing inputs as (numerical_features, categorical_features) changes the model
- # input signature to (<tensor, [list of tensors]>).
- # This leads to errors while loading the saved model.
- # TF flattens the inputs while loading the model,
- # so the inputs are converted from (<tensor, [list of tensors]>) -> [list of tensors]
- # see _set_inputs function in training_v1.py:
- # https://github.com/tensorflow/tensorflow/blob/7628750678786f1b65e8905fb9406d8fbffef0db/tensorflow/python/keras/engine/training_v1.py#L2588)
- inputs = OrderedDict()
- inputs['numerical_features'] = numerical_features
- inputs['categorical_features'] = categorical_features
- return inputs
|