tensorflow 之 tf.shape()
运行环境 : python 3.6.0
第三方库 : tensorflow 1.9.0
tf.shape()
shape(
input,
name=None,
out_type=dtypes.int32
)
例如 :
将矩阵的维度输出为一个维度矩阵 :
# -*- encoding: utf-8 -*-
import tensorflow as tf
import numpy as np
A = np.array([
[
[1, 1, 1],
[2, 2, 2]
],
[
[3, 3, 3],
[4, 4, 4],
],
[
[5, 5, 5],
[6, 6, 6],
]
])
t = tf.shape(A)
with tf.Session() as sess:
print(sess.run(t))
# 输出 :
"""
[3 2 3]
"""
参数 :
- input:张量或稀疏张量
- name:op 的名字,用于tensorboard中
- out_type:默认为tf.int32
返回值:
- 返回out_type类型的张量
还没有评论,来说两句吧...