tf.compat.v1.to_int32
Преобразует тензор в тип int32. (устарела)
tf.compat.v1.to_int32(
x, name='ToInt32'
)
Переход на TF2
Это имя устарело и было удалено в TF2, но у него есть точная замена: tf.cast(..., tf.int32). При eager execution или использовании 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/api_docs/python/tf/compat/v1/to_int32