mindspore.amp.all_finite

View Source On Gitee
mindspore.amp.all_finite(inputs)[source]

Returns a scalar Tensor indicating whether the inputs are finite.

Warning

This is an experimental API that is subject to change or deletion.

The interface must be used in whole network training scenario to detect whether grads are finite, and the results may be different on different device targets.

Parameters

inputs (Union(tuple(Tensor), list(Tensor))) – a iterable Tensor.

Returns

Tensor, a scalar Tensor and the dtype is bool.

Supported Platforms:

Ascend GPU CPU

Examples

>>> from mindspore import amp, Tensor
>>> import numpy as np
>>> x = (Tensor(np.array([np.log(-1), 1, np.log(0)])), Tensor(np.array([1.0])))
>>> output = amp.all_finite(x)
Tutorial Examples: