mygrad.log#

class mygrad.log(x1: ArrayLike, out: Optional[Union[Tensor, ndarray]] = None, *, where: Mask = True, dtype: DTypeLikeReals = None, constant: Optional[bool] = None)#

Natural logarithm, element-wise.

The natural logarithm log is the inverse of the exponential function, so that log(exp(x)) = x. The natural logarithm is logarithm in base e.

This docstring was adapted from that of numpy.log [1]

Parameters
x1ArrayLike

Input value.

outOptional[Union[Tensor, ndarray]]

A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated tensor is returned.

constantOptional[bool]

If True, this tensor is treated as a constant, and thus does not facilitate back propagation (i.e. constant.grad will always return None).

Defaults to False for float-type data. Defaults to True for integer-type data.

Integer-type tensors must be constant.

whereMask

This condition is broadcast over the input. At locations where the condition is True, the out tensor will be set to the ufunc result. Elsewhere, the out tensor will retain its original value. Note that if an uninitialized out tensor is created via the default out=None, locations within it where the condition is False will remain uninitialized.

dtypeOptional[DTypeLikeReals]

The dtype of the resulting tensor.

Returns
logTensor

f(x1) computed element-wise

See also

log10, log2, log1p

Notes

Logarithm is a multivalued function: for each x there is an infinite number of z such that exp(z) = x. The convention is to return the z whose imaginary part lies in [-pi, pi].

For real-valued input data types, log always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag.

For complex-valued input, log is a complex analytical function that has a branch cut [-inf, 0] and is continuous from above on it. log handles the floating-point negative zero as an infinitesimal negative number, conforming to the C99 standard.

References

1

Retrieved from https://numpy.org/doc/stable/reference/generated/numpy.log.html

Examples

>>> import mygrad as mg
>>> mg.log([1, mg.e, mg.e**2, 0])
array([  0.,   1.,   2., -Inf])
Attributes
identity
signature

Methods

accumulate([axis, dtype, out, constant])

Not implemented

at(indices[, b, constant])

Not implemented

outer(b, *[, dtype, out])

Not Implemented

reduce([axis, dtype, out, keepdims, ...])

Not Implemented

reduceat(indices[, axis, dtype, out])

Not Implemented

__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

accumulate([axis, dtype, out, constant])

Not implemented

at(indices[, b, constant])

Not implemented

outer(b, *[, dtype, out])

Not Implemented

reduce([axis, dtype, out, keepdims, ...])

Not Implemented

reduceat(indices[, axis, dtype, out])

Not Implemented

Attributes

identity

nargs

nin

nout

ntypes

signature

types