When I attempt to use tf.map_fn in the definition of a keras Functional model, I get the error:
TypeError: Could not build a TypeSpec for <KerasTensor: ...
e.g. this simple model will trigger that error in tf-nightly 2.5.0 :
import tensorflow as tf
from tensorflow.keras.layers import Input
from tensorflow.keras.models import Model
x = Input(shape=(10,))
y = tf.map_fn(lambda x : x * 2, x, fn_output_signature=tf.float32)
model = Model(inputs=x, outputs=y)
Whereas replacing the call to tf.map_fn to calls to other tensorflow operations works fine.