Need Help with a TypeError in Tft Preprocess_fn

Getting an error while trying to cast float32 to int64

TypeError: Failed to convert object of type <class ‘tensorflow.python.framework.sparse_tensor.SparseTensor’> to Tensor. Contents: SparseTensor(indices=Tensor(“F_traffic_volume/Placeholder:0”, shape=(None, 2), dtype=int64), values=Tensor(“F_traffic_volume/Placeholder_1:0”, shape=(None,), dtype=int64), dense_shape=Tensor(“F_traffic_volume/Placeholder_2:0”, shape=(2,), dtype=int64)). Consider casting elements to a supported type.

Code used :

2 Likes

Hi! Welcome to Discourse! Hmmm… your code looks correct. Maybe the problem is with the other cells. Can you check first if you’re running the component with context.run(transform, enable_cache=False)? It might be that you made a mistake earlier but the correction is not being reflected because the cache is on.

1 Like