因为实验设置需要获取tf.placeholder()定义的维度的参数(三维的),开始使用tf.shape()发现shape是一维的,不能获得具体的维度,查找资料之后发现可以使用 .shape.as_list()发放获取具体的维度。
测试代码如下:
import tensorflow as tf
test = tf.placeholder(tf.float32,shape=[None,4,1])
test_shape_1 =tf.shape(test)
print('test_shape_1:',test_shape_1)
test_shape_2=test.shape.as_list()
print('test_sahpe_2',test_shape_2)
print('test_shape_2 First dimendion',test_shape_2[0])#获取第一个维度值
test_dynamic = tf.unstack(tf.shape(test))
print('test_dynammic:',test_dynamic)
结果如下: