这是在TensorFlow 1.11.0上。tft.apply_buckets
的documentation不是很有描述性。具体来说,我读到:
“桶边界:用秩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
不应该是索引和边界。有人知道如何正确使用这个方法吗?你知道吗
经过一番研究,我发现
bucket_boundaries
应该是一个二维数组,其中条目是bucket边界,数组被包装成两列。见下例:因此,预期输入为:
相关问题 更多 >
编程相关推荐