jax.numpy.fromstring#

jax.numpy.fromstring(string, dtype=<class 'float'>, count=-1, *, sep)[source]#

Convert a string of text into 1-D JAX array.

JAX implementation of numpy.fromstring().

Parameters:
  • string (str) – input string containing the data.

  • dtype (DTypeLike) – optional. Desired data type for the array. Default is float.

  • count (int) – optional integer specifying the number of items to read from the string. If -1 (default), all items are read.

  • sep (str) – the string used to separate values in the input string.

Returns:

A 1-D JAX array containing the parsed data from the input string.

Return type:

Array

See also

Examples

>>> jnp.fromstring("1 2 3", dtype=int, sep=" ")
Array([1, 2, 3], dtype=int32)
>>> jnp.fromstring("0.1, 0.2, 0.3", dtype=float, count=2, sep=",")
Array([0.1, 0.2], dtype=float32)