I'm having some difficulty understanding the return types of structured_input_signature
when inspecting a tf.ConcreteFunction
.
In the google docs https://www.tensorflow.org/guide/concrete_function#using_a_concrete_function a tuple is returned. For example
@tf.function
def power(a,b):
print('Tracing "power"\n')
return a**b
float_power = power.get_concrete_function(
a = tf.TensorSpec(shape=[], dtype=tf.float32),
b = tf.TensorSpec(shape=[], dtype=tf.float32))
print(float_power.structured_input_signature)
print(float_power.structured_outputs)
prints
Tracing "power"
((TensorSpec(shape=(), dtype=tf.float32, name='a'), TensorSpec(shape=(), dtype=tf.float32, name='b')), {})
Tensor("Identity:0", shape=(), dtype=float32)
However, when the module is saved and loaded, the output of is slightly different:
float_power_mod = tf.Module()
float_power_mod.float_power = float_power
tf.saved_model.save(float_power_mod, './float_power_mod')
mod_4 = tf.saved_model.load('./float_power_mod')
float_power_func = mod_4.signatures['serving_default']
print(float_power_func.structured_input_signature)
prints
((),
{'a': TensorSpec(shape=(), dtype=tf.float32, name='a'),
'b': TensorSpec(shape=(), dtype=tf.float32, name='b')})
What's the logic behind populating the tuple vs the dict in the return tuple of structured_input_signature?