cast

dragon.cast(
  inputs,
  dtype,
  copy=True,
  **kwargs
)[source]

Convert the data type of input.

Examples:

x = dragon.constant([1, 2, 3], dtype='int64')
print(dragon.cast(x, dtype='float32'))
Parameters:
  • inputs (dragon.Tensor) – The input tensor.
  • dtype (str) – The data type to convert to.
  • copy (bool, optional, default=True) – Return a new tensor or call in-place.
Returns:

dragon.Tensor – The output tensor.