jax.Array.astype#

抽象 Array.astype(dtype, copy=False, device=None)[源码]#

复制数组并转换为指定的数据类型。

此功能通过 jax.lax.convert_element_type() 实现,在某些情况下其行为可能与 numpy.ndarray.astype() 略有不同。特别是,浮点数到整数和整数到浮点的转换细节取决于实现。

参数:
  • self (Array)

  • dtype (DTypeLike | None)

  • copy (bool)

  • device (xc.Device | Sharding | None)

返回类型:

Array