ones_like

ivy.ones_like(x, dtype_str=None, dev_str=None, f=None)[source]

Returns an array of ones with the same shape and type as x, unless dtype_str provided which overrides.

Parameters
  • x (array) – The shape and data-type of a define these same attributes of the returned array.

  • dtype_str (data-type string, optional) – The desired data-type for the array in string format, i.e. ‘float32’ or ‘int64’. If not given, then the type of the original array is used.

  • dev_str (str, optional) – device on which to create the array ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. Same as x if None.

  • f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.

Returns

Tensor of zeros with the same shape and type as a, unless dtype_str provided which overrides.


Supported Frameworks:

empty jax_logo empty tf_logo empty pytorch_logo empty mxnet_logo empty numpy_logo empty