Exemplo n.º 1
0
def square(a):
    """Calculate the square of input.

    Parameters
    ----------
    a : Tensor
        The input tensor.

    Returns
    -------
    Tensor
        The square result.

    """
    return ops.Square(a)
Exemplo n.º 2
0
def square(x, name=None):
    """
    Computes square of x element-wise.

      I.e., \\(y = x * x = x^2\\).

      Args:
        x: A `Tensor`.
        name: A name for the operation (optional).

      Returns:
        A `Tensor`. Has the same type as `x`.

    """

    return ops.Square(x, name=name)
Exemplo n.º 3
0
def l2_loss(t, name=None):
    """
    Computes half the L2 norm of a tensor without the sqrt:

      output = sum(t ** 2) / 2

      Args:
        t:  A Tensor. Typically 2-D, but may have any dimensions.
        name: Optional name for the operation.

      Returns:
        A Tensor. Has the same type as t. 0-D.

    """

    return (ops.Reduce(ops.Square(t), operation='SUM') * 0.5)
Exemplo n.º 4
0
def square(x, name=None):

    return ops.Square(x, name=name)
Exemplo n.º 5
0
def l2_loss(t, name=None):
    return (ops.Reduce(ops.Square(t), operation='SUM') * 0.5)