Exemple #1
0
 def call(self, inputs):
     if ragged_tensor.is_ragged(inputs):
         integer_buckets = ragged_functional_ops.map_flat_values(
             gen_math_ops.Bucketize, input=inputs, boundaries=self.bins)
         # Ragged map_flat_values doesn't touch the non-values tensors in the
         # ragged composite tensor. If this op is the only op a Keras model,
         # this can cause errors in Graph mode, so wrap the tensor in an identity.
         return array_ops.identity(integer_buckets)
     elif isinstance(inputs, sparse_tensor.SparseTensor):
         integer_buckets = gen_math_ops.Bucketize(input=inputs.values,
                                                  boundaries=self.bins)
         return sparse_tensor.SparseTensor(
             indices=array_ops.identity(inputs.indices),
             values=integer_buckets,
             dense_shape=array_ops.identity(inputs.dense_shape))
     else:
         return gen_math_ops.Bucketize(input=inputs, boundaries=self.bins)
Exemple #2
0
 def bucketize(inputs):
     return gen_math_ops.Bucketize(input=inputs,
                                   boundaries=self.bin_boundaries)