tf.compat.v1.to_int32
Преобразование тензора к типу int32. (устаревшее)
tf.compat.v1.to_int32(
x, name='ToInt32'
)
Переход на TF2
Это имя было устаревшим и удалено в TF2, но имеет точный заменитель tf.cast(..., tf.int32). Не возникает проблем с выполнением Eager или tf.function.
До:
tf.compat.v1.to_int32(tf.constant(1, dtype=tf.int64)) <tf.Tensor: shape=(), dtype=int32, numpy=1>
После:
tf.cast(tf.constant(1, dtype=tf.int64), tf.int32) <tf.Tensor: shape=(), dtype=int32, numpy=1>
Описание
| Аргументы | |
|---|---|
x | Tensor или SparseTensor или IndexedSlices. |
name | Имя операции (необязательно). |
| Возвращаемое значение | |
|---|---|
Tensor или SparseTensor или IndexedSlices с той же формой, что и x, но с типом int32. |
| Исключения | |
|---|---|
TypeError | Если x нельзя преобразовать в int32. |
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/compat/v1/to_int32