tf.keras.Model获取输出tensor name

1.从keras.Model获取output name
from tensorflow.python.keras.saving import saving_utils
function = saving_utils.trace_model_call(model)
concrete_func = function.get_concrete_function()
print(concrete_func.structured_outputs)

print(concrete_func.structured_input_signature)
#或者
input_names = [input_tensor.name for input_tensor in concrete_func.inputs
                if input_tensor.dtype != tf.dtypes.resource]
print(input_names)
posted @ 2022-05-11 16:33  灰太狼锅锅  阅读(171)  评论(0编辑  收藏  举报