chainer.functions.cast¶
-
chainer.functions.
cast
(x, typ)[source]¶ Cast an input variable to a given type.
Parameters: - x (
Variable
ornumpy.ndarray
orcupy.ndarray
) – Input variable to be casted. A \((s_1, s_2, ..., s_N)\)-shaped float array. - typ (
str
of dtype ornumpy.dtype
) – Typecode or data type to cast.
Returns: Variable holding a casted array.
Return type: Example
>>> x = np.arange(0, 3, dtype=np.float64) >>> x.dtype dtype('float64') >>> y = F.cast(x, np.float32) >>> y.dtype dtype('float32') >>> y = F.cast(x, 'float16') >>> y.dtype dtype('float16')
- x (