1# Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================== 15"""Wrappers for bucketization operations.""" 16from __future__ import absolute_import 17from __future__ import division 18from __future__ import print_function 19 20from tensorflow.python.ops import math_ops 21 22 23def bucketize(input_tensor, boundaries, name=None): 24 """Bucketizes input_tensor by given boundaries. 25 26 See bucketize_op.cc for more details. 27 28 Args: 29 input_tensor: A `Tensor` which will be bucketize. 30 boundaries: A list of floats gives the boundaries. It has to be sorted. 31 name: A name prefix for the returned tensors (optional). 32 33 Returns: 34 A `Tensor` with type int32 which indicates the corresponding bucket for 35 each value in `input_tensor`. 36 37 Raises: 38 TypeError: If boundaries is not a list. 39 """ 40 return math_ops._bucketize( # pylint: disable=protected-access 41 input_tensor, boundaries=boundaries, name=name) 42