将张量转换为 int32 类型
生活随笔
收集整理的這篇文章主要介紹了
将张量转换为 int32 类型
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
tf.to_int32函數:
tf.to_int32(x,name='ToInt32' )函數參數:
- x:一個?Tensor 、SparseTensor、list或ndarray
- name:操作的名稱(可選)。
函數返回值:
tf.to_int32函數返回一個 Tensor 或 SparseTensor,與 x (類型為 int32)具有相同的形狀。
例子:
import numpy as np import tensorflow as tfa = [[1,2,3], [2,3,4]] b = np.array([[1,2,3], [2,3,4]]) c = tf.convert_to_tensor([[1,2,3], [2,3,4]]) d = tf.to_int32(a) e = tf.to_int32(b) f = tf.to_int32(c) sess = tf.InteractiveSession() print(sess.run(d)) print(sess.run(e)) print(sess.run(f))?
總結
以上是生活随笔為你收集整理的将张量转换为 int32 类型的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C++一维数组指针详解
- 下一篇: PPT将图片变为平行四边形形状