这是在 TensorFlow 1.11.0 上。的文档描述性tft.apply_buckets
不是很强。具体来说,我读到:“bucket_boundaries:桶边界表示为 2 阶张量。”
我认为这必须是存储桶索引和存储桶边界?
当我尝试使用下面的玩具示例时:
import tensorflow as tf
import tensorflow_transform as tft
import numpy as np
tf.enable_eager_execution()
x = np.array([-1,9,19, 29, 39])
xt = tf.cast(
tf.convert_to_tensor(x),
tf.float32
)
boundaries = tf.cast(
tf.transpose(
tf.convert_to_tensor([[0, 1, 2, 3], [10, 20, 30, 40]])
),
tf.float32
)
buckets = tft.apply_buckets(xt, boundaries)
我得到:
InvalidArgumentError: Expected sorted boundaries [Op:BucketizeWithInputBoundaries] name: assign_buckets
请注意,在这种情况下x
,bucket_boundaries
参数是:
tf.Tensor([-1. 9. 19. 29. 39.], shape=(5,), dtype=float32)
tf.Tensor(
[[ 0. 10.]
[ 1. 20.]
[ 2. 30.]
[ 3. 40.]], shape=(4, 2), dtype=float32)
因此,似乎bucket_boundaries
不应该是索引和边界。有谁知道如何正确使用这种方法?