aesara.tensor.as_tensor

Contents

aesara.tensor.as_tensor#

aesara.tensor.as_tensor(x: Variable | Sequence[Variable] | ArrayLike, name: str | None = None, ndim: int | None = None, **kwargs) TensorVariable[source]#

Convert x into an equivalent TensorVariable.

This function can be used to turn ndarrays, numbers, ScalarType instances, Apply instances and TensorVariable instances into valid input list elements.

See aesara.as_symbolic for a more general conversion function.

Parameters:
  • x – The object to be converted into a Variable type. A numpy.ndarray argument will not be copied, but a list of numbers will be copied to make an numpy.ndarray.

  • name – If a new Variable instance is created, it will be named with this string.

  • ndim – Return a Variable with this many dimensions.

  • dtype – The dtype to use for the resulting Variable. If x is already a Variable type, then the dtype will not be changed.

Raises:

TypeError – If x cannot be converted to a TensorVariable.