Exemplo n.º 1
0
@np_utils.np_doc('bitwise_and')
def bitwise_and(x1, x2):
    return _bitwise_binary_op(bitwise_ops.bitwise_and, x1, x2)


@np_utils.np_doc('bitwise_or')
def bitwise_or(x1, x2):
    return _bitwise_binary_op(bitwise_ops.bitwise_or, x1, x2)


@np_utils.np_doc('bitwise_xor')
def bitwise_xor(x1, x2):
    return _bitwise_binary_op(bitwise_ops.bitwise_xor, x1, x2)


@np_utils.np_doc('bitwise_not', link=np_utils.AliasOf('invert'))
def bitwise_not(x):
    def f(x):
        if x.dtype == dtypes.bool:
            return math_ops.logical_not(x)
        return bitwise_ops.invert(x)

    return _scalar(f, x)


def _scalar(tf_fn, x, promote_to_float=False):
    """Computes the tf_fn(x) for each element in `x`.

  Args:
    tf_fn: function that takes a single Tensor argument.
    x: array_like. Could be an ndarray, a Tensor or any object that can be
Exemplo n.º 2
0
from tensorflow.python.ops.array_ops import newaxis
from tensorflow.python.ops.numpy_ops import np_random as random
from tensorflow.python.ops.numpy_ops import np_utils
# pylint: disable=wildcard-import
from tensorflow.python.ops.numpy_ops.np_array_ops import *
from tensorflow.python.ops.numpy_ops.np_arrays import ndarray
from tensorflow.python.ops.numpy_ops.np_config import *
from tensorflow.python.ops.numpy_ops.np_dtypes import *
from tensorflow.python.ops.numpy_ops.np_math_ops import *
# pylint: enable=wildcard-import
from tensorflow.python.ops.numpy_ops.np_utils import finfo
from tensorflow.python.ops.numpy_ops.np_utils import promote_types
from tensorflow.python.ops.numpy_ops.np_utils import result_type


# pylint: disable=redefined-builtin,undefined-variable
@np_utils.np_doc("max", link=np_utils.AliasOf("amax"))
def max(a, axis=None, keepdims=None):
  return amax(a, axis=axis, keepdims=keepdims)


@np_utils.np_doc("min", link=np_utils.AliasOf("amin"))
def min(a, axis=None, keepdims=None):
  return amin(a, axis=axis, keepdims=keepdims)


@np_utils.np_doc("round", link=np_utils.AliasOf("around"))
def round(a, decimals=0):
  return around(a, decimals=decimals)
# pylint: enable=redefined-builtin,undefined-variable