tensorflow: [help wanted] tf.strings.operations raises TypeError: Value passed to parameter 'input' has DataType string not in list of allowed

I’m just 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.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (2 by maintainers)

Most upvoted comments

@maifeeulasad ,The issue escalated to concern developer as a potential feature request.Thanks!

@maifeeulasad , It seems some of the strings Ops not working inside models.For example tf.strings.split() not working with model whereas tf.strings.lower() working fine which might be due to difference in implementation for reasons unknown to me.Please refer to attached gist.

Thank you!