Efficient way to filter tf.data based on a string value

Viewed 255

I am looking for a solution to efficiently filter the samples in tf.data based on a string value as: x = x.filter(lambda data: tf.math.equal(data, value)) though it works but the approach is really slow and if combined with map operations it becomes even more slower. Is there any solution that is fast?

Example instance:

FeaturesDict({
    'x': DummyObject(shape=(None,), dtype=tf.float32),
    'y': DummyObject(shape=(), dtype=tf.int64),
    'id': tf.string,
})
0 Answers
Related