mygrad.exp#

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

Calculate the exponential of all elements in the input tensor.

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

Parameters
x1ArrayLike

Input values.

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
expTensor

f(x1) computed element-wise

See also

expm1

Calculate exp(x) - 1 for all elements in the tensor.

exp2

Calculate 2**x for all elements in the tensor.

Notes

The irrational number e is also known as Euler’s number. It is approximately 2.718281, and is the base of the natural logarithm, ln (this means that, if \(x = \ln y = \log_e y\), then \(e^x = y\). For real input, exp(x) is always positive.

References

1

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

Examples

>>> import mygrad as mg
>>> x = mg.tensor(1.)
>>> f = mg.exp(x); f  # f(1.)
Tensor(2.71828183)

Evaluate df/dx at x = 1.

>>> f.backward()
>>> x.grad
>>> x.grad  # df/dx @ x=1
array(2.71828183)
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