Python numpy.greater() Examples
The following are 30 code examples for showing how to use numpy.greater(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example 1
Project: Att-ChemdNER Author: lingluodlut File: utils.py License: Apache License 2.0 | 6 votes |
def __init__(self, monitor='val_loss', min_delta=1e-6, patience=5,mode='min'): #{{{ super(EarlyStopping, self).__init__() self.monitor = monitor self.patience = patience self.min_delta = min_delta self.wait = 0 self.stopped_epoch = 0 self.stop_training=False; if mode =="min": self.monitor_op = np.less; elif mode == "max": self.monitor_op = np.greater; else: assert 0,"unknown early stop mode:"; self.min_delta *= -1 #}}}
Example 2
Project: dynamic-training-with-apache-mxnet-on-aws Author: awslabs File: onnx_import_test.py License: Apache License 2.0 | 6 votes |
def test_greater(): """Test for logical greater in onnx operators.""" input1 = np.random.rand(1, 3, 4, 5).astype("float32") input2 = np.random.rand(1, 5).astype("float32") inputs = [helper.make_tensor_value_info("input1", TensorProto.FLOAT, shape=(1, 3, 4, 5)), helper.make_tensor_value_info("input2", TensorProto.FLOAT, shape=(1, 5))] outputs = [helper.make_tensor_value_info("output", TensorProto.FLOAT, shape=(1, 3, 4, 5))] nodes = [helper.make_node("Greater", ["input1", "input2"], ["output"])] graph = helper.make_graph(nodes, "greater_test", inputs, outputs) greater_model = helper.make_model(graph) bkd_rep = mxnet_backend.prepare(greater_model) numpy_op = np.greater(input1, input2).astype(np.float32) output = bkd_rep.run([input1, input2]) npt.assert_almost_equal(output[0], numpy_op)
Example 3
Project: dynamic-training-with-apache-mxnet-on-aws Author: awslabs File: onnx_import_test.py License: Apache License 2.0 | 6 votes |
def test_lesser(): """Test for logical greater in onnx operators.""" input1 = np.random.rand(1, 3, 4, 5).astype("float32") input2 = np.random.rand(1, 5).astype("float32") inputs = [helper.make_tensor_value_info("input1", TensorProto.FLOAT, shape=(1, 3, 4, 5)), helper.make_tensor_value_info("input2", TensorProto.FLOAT, shape=(1, 5))] outputs = [helper.make_tensor_value_info("output", TensorProto.FLOAT, shape=(1, 3, 4, 5))] nodes = [helper.make_node("Less", ["input1", "input2"], ["output"])] graph = helper.make_graph(nodes, "lesser_test", inputs, outputs) greater_model = helper.make_model(graph) bkd_rep = mxnet_backend.prepare(greater_model) numpy_op = np.less(input1, input2).astype(np.float32) output = bkd_rep.run([input1, input2]) npt.assert_almost_equal(output[0], numpy_op)
Example 4
Project: dynamic-training-with-apache-mxnet-on-aws Author: awslabs File: onnx_import_test.py License: Apache License 2.0 | 6 votes |
def test_equal(): """Test for logical greater in onnx operators.""" input1 = np.random.rand(1, 3, 4, 5).astype("float32") input2 = np.random.rand(1, 5).astype("float32") inputs = [helper.make_tensor_value_info("input1", TensorProto.FLOAT, shape=(1, 3, 4, 5)), helper.make_tensor_value_info("input2", TensorProto.FLOAT, shape=(1, 5))] outputs = [helper.make_tensor_value_info("output", TensorProto.FLOAT, shape=(1, 3, 4, 5))] nodes = [helper.make_node("Equal", ["input1", "input2"], ["output"])] graph = helper.make_graph(nodes, "equal_test", inputs, outputs) greater_model = helper.make_model(graph) bkd_rep = mxnet_backend.prepare(greater_model) numpy_op = np.equal(input1, input2).astype(np.float32) output = bkd_rep.run([input1, input2]) npt.assert_almost_equal(output[0], numpy_op)
Example 5
Project: gnocchi Author: gnocchixyz File: operations.py License: Apache License 2.0 | 6 votes |
def handle_rolling(agg, granularity, timestamps, values, is_aggregated, references, window): if window > len(values): raise exceptions.UnAggregableTimeseries( references, "Rolling window '%d' is greater than serie length '%d'" % (window, len(values)) ) timestamps = timestamps[window - 1:] values = values.T # rigtorp.se/2011/01/01/rolling-statistics-numpy.html shape = values.shape[:-1] + (values.shape[-1] - window + 1, window) strides = values.strides + (values.strides[-1],) new_values = AGG_MAP[agg](as_strided(values, shape=shape, strides=strides), axis=-1) if agg.startswith("rate:"): timestamps = timestamps[1:] return granularity, timestamps, new_values.T, is_aggregated
Example 6
Project: recruit Author: Frank-qlu File: test_datetime.py License: Apache License 2.0 | 6 votes |
def test_datetime_compare_nat(self): dt_nat = np.datetime64('NaT', 'D') dt_other = np.datetime64('2000-01-01') td_nat = np.timedelta64('NaT', 'h') td_other = np.timedelta64(1, 'h') for op in [np.equal, np.less, np.less_equal, np.greater, np.greater_equal]: assert_(not op(dt_nat, dt_nat)) assert_(not op(dt_nat, dt_other)) assert_(not op(dt_other, dt_nat)) assert_(not op(td_nat, td_nat)) assert_(not op(td_nat, td_other)) assert_(not op(td_other, td_nat)) assert_(np.not_equal(dt_nat, dt_nat)) assert_(np.not_equal(dt_nat, dt_other)) assert_(np.not_equal(dt_other, dt_nat)) assert_(np.not_equal(td_nat, td_nat)) assert_(np.not_equal(td_nat, td_other)) assert_(np.not_equal(td_other, td_nat))
Example 7
Project: recruit Author: Frank-qlu File: test_ufunc.py License: Apache License 2.0 | 6 votes |
def test_NotImplemented_not_returned(self): # See gh-5964 and gh-2091. Some of these functions are not operator # related and were fixed for other reasons in the past. binary_funcs = [ np.power, np.add, np.subtract, np.multiply, np.divide, np.true_divide, np.floor_divide, np.bitwise_and, np.bitwise_or, np.bitwise_xor, np.left_shift, np.right_shift, np.fmax, np.fmin, np.fmod, np.hypot, np.logaddexp, np.logaddexp2, np.logical_and, np.logical_or, np.logical_xor, np.maximum, np.minimum, np.mod, np.greater, np.greater_equal, np.less, np.less_equal, np.equal, np.not_equal] a = np.array('1') b = 1 c = np.array([1., 2.]) for f in binary_funcs: assert_raises(TypeError, f, a, b) assert_raises(TypeError, f, c, a)
Example 8
Project: recruit Author: Frank-qlu File: defchararray.py License: Apache License 2.0 | 6 votes |
def equal(x1, x2): """ Return (x1 == x2) element-wise. Unlike `numpy.equal`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- not_equal, greater_equal, less_equal, greater, less """ return compare_chararrays(x1, x2, '==', True)
Example 9
Project: recruit Author: Frank-qlu File: defchararray.py License: Apache License 2.0 | 6 votes |
def not_equal(x1, x2): """ Return (x1 != x2) element-wise. Unlike `numpy.not_equal`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, greater_equal, less_equal, greater, less """ return compare_chararrays(x1, x2, '!=', True)
Example 10
Project: recruit Author: Frank-qlu File: defchararray.py License: Apache License 2.0 | 6 votes |
def greater_equal(x1, x2): """ Return (x1 >= x2) element-wise. Unlike `numpy.greater_equal`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, not_equal, less_equal, greater, less """ return compare_chararrays(x1, x2, '>=', True)
Example 11
Project: recruit Author: Frank-qlu File: defchararray.py License: Apache License 2.0 | 6 votes |
def less_equal(x1, x2): """ Return (x1 <= x2) element-wise. Unlike `numpy.less_equal`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, not_equal, greater_equal, greater, less """ return compare_chararrays(x1, x2, '<=', True)
Example 12
Project: recruit Author: Frank-qlu File: defchararray.py License: Apache License 2.0 | 6 votes |
def greater(x1, x2): """ Return (x1 > x2) element-wise. Unlike `numpy.greater`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, not_equal, greater_equal, less_equal, less """ return compare_chararrays(x1, x2, '>', True)
Example 13
Project: lambda-packs Author: ryfeus File: defchararray.py License: MIT License | 6 votes |
def equal(x1, x2): """ Return (x1 == x2) element-wise. Unlike `numpy.equal`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- not_equal, greater_equal, less_equal, greater, less """ return compare_chararrays(x1, x2, '==', True)
Example 14
Project: lambda-packs Author: ryfeus File: defchararray.py License: MIT License | 6 votes |
def not_equal(x1, x2): """ Return (x1 != x2) element-wise. Unlike `numpy.not_equal`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, greater_equal, less_equal, greater, less """ return compare_chararrays(x1, x2, '!=', True)
Example 15
Project: lambda-packs Author: ryfeus File: defchararray.py License: MIT License | 6 votes |
def greater_equal(x1, x2): """ Return (x1 >= x2) element-wise. Unlike `numpy.greater_equal`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, not_equal, less_equal, greater, less """ return compare_chararrays(x1, x2, '>=', True)
Example 16
Project: lambda-packs Author: ryfeus File: defchararray.py License: MIT License | 6 votes |
def less_equal(x1, x2): """ Return (x1 <= x2) element-wise. Unlike `numpy.less_equal`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, not_equal, greater_equal, greater, less """ return compare_chararrays(x1, x2, '<=', True)
Example 17
Project: lambda-packs Author: ryfeus File: defchararray.py License: MIT License | 6 votes |
def greater(x1, x2): """ Return (x1 > x2) element-wise. Unlike `numpy.greater`, this comparison is performed by first stripping whitespace characters from the end of the string. This behavior is provided for backward-compatibility with numarray. Parameters ---------- x1, x2 : array_like of str or unicode Input arrays of the same shape. Returns ------- out : ndarray or bool Output array of bools, or a single bool if x1 and x2 are scalars. See Also -------- equal, not_equal, greater_equal, less_equal, less """ return compare_chararrays(x1, x2, '>', True)
Example 18
Project: lambda-packs Author: ryfeus File: data.py License: MIT License | 6 votes |
def argmax(self, axis=None, out=None): """Return indices of maximum elements along an axis. Implicit zero elements are also taken into account. If there are several maximum values, the index of the first occurrence is returned. Parameters ---------- axis : {-2, -1, 0, 1, None}, optional Axis along which the argmax is computed. If None (default), index of the maximum element in the flatten data is returned. out : None, optional This argument is in the signature *solely* for NumPy compatibility reasons. Do not pass in anything except for the default value, as this argument is not used. Returns ------- ind : np.matrix or int Indices of maximum elements. If matrix, its size along `axis` is 1. """ return self._arg_min_or_max(axis, out, np.argmax, np.greater)
Example 19
Project: lambda-packs Author: ryfeus File: callbacks.py License: MIT License | 6 votes |
def _reset(self): """Resets wait counter and cooldown counter. """ if self.mode not in ['auto', 'min', 'max']: warnings.warn('Learning Rate Plateau Reducing mode %s is unknown, ' 'fallback to auto mode.' % (self.mode), RuntimeWarning) self.mode = 'auto' if (self.mode == 'min' or (self.mode == 'auto' and 'acc' not in self.monitor)): self.monitor_op = lambda a, b: np.less(a, b - self.epsilon) self.best = np.Inf else: self.monitor_op = lambda a, b: np.greater(a, b + self.epsilon) self.best = -np.Inf self.cooldown_counter = 0 self.wait = 0 self.lr_epsilon = self.min_lr * 1e-4
Example 20
Project: lambda-packs Author: ryfeus File: test_core.py License: MIT License | 6 votes |
def test_minmax_func(self): # Tests minimum and maximum. (x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d # max doesn't work if shaped xr = np.ravel(x) xmr = ravel(xm) # following are true because of careful selection of data assert_equal(max(xr), maximum(xmr)) assert_equal(min(xr), minimum(xmr)) assert_equal(minimum([1, 2, 3], [4, 0, 9]), [1, 0, 3]) assert_equal(maximum([1, 2, 3], [4, 0, 9]), [4, 2, 9]) x = arange(5) y = arange(5) - 2 x[3] = masked y[0] = masked assert_equal(minimum(x, y), where(less(x, y), x, y)) assert_equal(maximum(x, y), where(greater(x, y), x, y)) assert_(minimum(x) == 0) assert_(maximum(x) == 4) x = arange(4).reshape(2, 2) x[-1, -1] = masked assert_equal(maximum(x), 2)
Example 21
Project: auto-alt-text-lambda-api Author: abhisuri97 File: test_deprecations.py License: MIT License | 6 votes |
def test_identity_equality_mismatch(self): a = np.array([np.nan], dtype=object) with warnings.catch_warnings(): warnings.filterwarnings('always', '', FutureWarning) assert_warns(FutureWarning, np.equal, a, a) assert_warns(FutureWarning, np.not_equal, a, a) with warnings.catch_warnings(): warnings.filterwarnings('error', '', FutureWarning) assert_raises(FutureWarning, np.equal, a, a) assert_raises(FutureWarning, np.not_equal, a, a) # And the other do not warn: with np.errstate(invalid='ignore'): np.less(a, a) np.greater(a, a) np.less_equal(a, a) np.greater_equal(a, a)
Example 22
Project: aospy Author: spencerahill File: longitude.py License: Apache License 2.0 | 5 votes |
def __lt__(self, other): if isinstance(other, Longitude): if self.hemisphere == 'W': if other.hemisphere == 'E': return True else: return self.longitude > other.longitude else: if other.hemisphere == 'W': return False else: return self.longitude < other.longitude else: return xr.apply_ufunc(np.greater, other, self)
Example 23
Project: neuropythy Author: noahbenson File: core.py License: GNU Affero General Public License v3.0 | 5 votes |
def nangt(x, y, nan_nan=False, nan_val=False, val_nan=False): ''' nangt(x, y) is equivalent to (x > y) except that NaN values in either x or y result in False. The following optional arguments may be provided: * nan_nan (default: False) specifies the return value (True or False) for comparisons equivalent to nangt(nan, nan). * nan_val (default: False) specifies the return value (True or False) for comparisons equivalent to nangt(nan, 0). * val_nan (default: False) specifies the return value (True or False) for comparisons equivalent to nangt(nan, 0). ''' return nan_compare(np.greater, x, y, nan_nan=nan_nan, nan_val=nan_val, val_nan=val_nan)
Example 24
Project: DOTA_models Author: ringringyi File: np_box_list_ops.py License: Apache License 2.0 | 5 votes |
def clip_to_window(boxlist, window): """Clip bounding boxes to a window. This op clips input bounding boxes (represented by bounding box corners) to a window, optionally filtering out boxes that do not overlap at all with the window. Args: boxlist: BoxList holding M_in boxes window: a numpy array of shape [4] representing the [y_min, x_min, y_max, x_max] window to which the op should clip boxes. Returns: a BoxList holding M_out boxes where M_out <= M_in """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) win_y_min = window[0] win_x_min = window[1] win_y_max = window[2] win_x_max = window[3] y_min_clipped = np.fmax(np.fmin(y_min, win_y_max), win_y_min) y_max_clipped = np.fmax(np.fmin(y_max, win_y_max), win_y_min) x_min_clipped = np.fmax(np.fmin(x_min, win_x_max), win_x_min) x_max_clipped = np.fmax(np.fmin(x_max, win_x_max), win_x_min) clipped = np_box_list.BoxList( np.hstack([y_min_clipped, x_min_clipped, y_max_clipped, x_max_clipped])) clipped = _copy_extra_fields(clipped, boxlist) areas = area(clipped) nonzero_area_indices = np.reshape(np.nonzero(np.greater(areas, 0.0)), [-1]).astype(np.int32) return gather(clipped, nonzero_area_indices)
Example 25
Project: DOTA_models Author: ringringyi File: np_box_list_ops.py License: Apache License 2.0 | 5 votes |
def prune_outside_window(boxlist, window): """Prunes bounding boxes that fall outside a given window. This function prunes bounding boxes that even partially fall outside the given window. See also ClipToWindow which only prunes bounding boxes that fall completely outside the window, and clips any bounding boxes that partially overflow. Args: boxlist: a BoxList holding M_in boxes. window: a numpy array of size 4, representing [ymin, xmin, ymax, xmax] of the window. Returns: pruned_corners: a tensor with shape [M_out, 4] where M_out <= M_in. valid_indices: a tensor with shape [M_out] indexing the valid bounding boxes in the input tensor. """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) win_y_min = window[0] win_x_min = window[1] win_y_max = window[2] win_x_max = window[3] coordinate_violations = np.hstack([np.less(y_min, win_y_min), np.less(x_min, win_x_min), np.greater(y_max, win_y_max), np.greater(x_max, win_x_max)]) valid_indices = np.reshape( np.where(np.logical_not(np.max(coordinate_violations, axis=1))), [-1]) return gather(boxlist, valid_indices), valid_indices
Example 26
Project: DOTA_models Author: ringringyi File: np_box_list_ops.py License: Apache License 2.0 | 5 votes |
def filter_scores_greater_than(boxlist, thresh): """Filter to keep only boxes with score exceeding a given threshold. This op keeps the collection of boxes whose corresponding scores are greater than the input threshold. Args: boxlist: BoxList holding N boxes. Must contain a 'scores' field representing detection scores. thresh: scalar threshold Returns: a BoxList holding M boxes where M <= N Raises: ValueError: if boxlist not a BoxList object or if it does not have a scores field """ if not isinstance(boxlist, np_box_list.BoxList): raise ValueError('boxlist must be a BoxList') if not boxlist.has_field('scores'): raise ValueError('input boxlist must have \'scores\' field') scores = boxlist.get_field('scores') if len(scores.shape) > 2: raise ValueError('Scores should have rank 1 or 2') if len(scores.shape) == 2 and scores.shape[1] != 1: raise ValueError('Scores should have rank 1 or have shape ' 'consistent with [None, 1]') high_score_indices = np.reshape(np.where(np.greater(scores, thresh)), [-1]).astype(np.int32) return gather(boxlist, high_score_indices)
Example 27
Project: object_detector_app Author: datitran File: np_box_list_ops.py License: MIT License | 5 votes |
def clip_to_window(boxlist, window): """Clip bounding boxes to a window. This op clips input bounding boxes (represented by bounding box corners) to a window, optionally filtering out boxes that do not overlap at all with the window. Args: boxlist: BoxList holding M_in boxes window: a numpy array of shape [4] representing the [y_min, x_min, y_max, x_max] window to which the op should clip boxes. Returns: a BoxList holding M_out boxes where M_out <= M_in """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) win_y_min = window[0] win_x_min = window[1] win_y_max = window[2] win_x_max = window[3] y_min_clipped = np.fmax(np.fmin(y_min, win_y_max), win_y_min) y_max_clipped = np.fmax(np.fmin(y_max, win_y_max), win_y_min) x_min_clipped = np.fmax(np.fmin(x_min, win_x_max), win_x_min) x_max_clipped = np.fmax(np.fmin(x_max, win_x_max), win_x_min) clipped = np_box_list.BoxList( np.hstack([y_min_clipped, x_min_clipped, y_max_clipped, x_max_clipped])) clipped = _copy_extra_fields(clipped, boxlist) areas = area(clipped) nonzero_area_indices = np.reshape(np.nonzero(np.greater(areas, 0.0)), [-1]).astype(np.int32) return gather(clipped, nonzero_area_indices)
Example 28
Project: object_detector_app Author: datitran File: np_box_list_ops.py License: MIT License | 5 votes |
def prune_outside_window(boxlist, window): """Prunes bounding boxes that fall outside a given window. This function prunes bounding boxes that even partially fall outside the given window. See also ClipToWindow which only prunes bounding boxes that fall completely outside the window, and clips any bounding boxes that partially overflow. Args: boxlist: a BoxList holding M_in boxes. window: a numpy array of size 4, representing [ymin, xmin, ymax, xmax] of the window. Returns: pruned_corners: a tensor with shape [M_out, 4] where M_out <= M_in. valid_indices: a tensor with shape [M_out] indexing the valid bounding boxes in the input tensor. """ y_min, x_min, y_max, x_max = np.array_split(boxlist.get(), 4, axis=1) win_y_min = window[0] win_x_min = window[1] win_y_max = window[2] win_x_max = window[3] coordinate_violations = np.hstack([np.less(y_min, win_y_min), np.less(x_min, win_x_min), np.greater(y_max, win_y_max), np.greater(x_max, win_x_max)]) valid_indices = np.reshape( np.where(np.logical_not(np.max(coordinate_violations, axis=1))), [-1]) return gather(boxlist, valid_indices), valid_indices
Example 29
Project: object_detector_app Author: datitran File: np_box_list_ops.py License: MIT License | 5 votes |
def filter_scores_greater_than(boxlist, thresh): """Filter to keep only boxes with score exceeding a given threshold. This op keeps the collection of boxes whose corresponding scores are greater than the input threshold. Args: boxlist: BoxList holding N boxes. Must contain a 'scores' field representing detection scores. thresh: scalar threshold Returns: a BoxList holding M boxes where M <= N Raises: ValueError: if boxlist not a BoxList object or if it does not have a scores field """ if not isinstance(boxlist, np_box_list.BoxList): raise ValueError('boxlist must be a BoxList') if not boxlist.has_field('scores'): raise ValueError('input boxlist must have \'scores\' field') scores = boxlist.get_field('scores') if len(scores.shape) > 2: raise ValueError('Scores should have rank 1 or 2') if len(scores.shape) == 2 and scores.shape[1] != 1: raise ValueError('Scores should have rank 1 or have shape ' 'consistent with [None, 1]') high_score_indices = np.reshape(np.where(np.greater(scores, thresh)), [-1]).astype(np.int32) return gather(boxlist, high_score_indices)
Example 30
Project: lightnn Author: l11x0m7 File: activations.py License: Apache License 2.0 | 5 votes |
def thresholded_relu(z, theta=1.0): z = np.asarray(z) return z * (np.greater(z, theta).astype(np.float64))