I’m trying to create a superficial layer to pre-process data inside models. Here is an my Layer:
class StringLayer(tf.keras.layers.Layer):
def __init__(self):
super(StringLayer, self).__init__()
def call(self, inputs):
return tf.strings.join([some_python_function(word) for word in tf.strings.split(tf.strings.as_string(inputs), sep=" " )], separator=" ")
#model = tf.keras.models.Sequential()
#model.add(tf.keras.Input(shape=(1,), dtype=tf.string))
#model.add(StringLayer())
But it keeps giving me: TypeError: Value passed to parameter 'input' has DataType string not in list of allowed values: float32, float64, int32, uint8, int16, int8, int64, bfloat16, uint16, float16, uint32, uint64, complex64, complex128, bool, variant
I know I can do this thing out of the model, but my main goal is to somehow do this inside the model; this way, I’ll be able to maximize the GPU utilization.