is_fully_defined() 是tensorflow中tensor_shape下的一个函数,用于判断tensor_shape中的元素是不是全部已知。
举例如下:
import tensorflow.compat.v1 as tf
tensor_test1 =tf.placeholder(shape=(None,256,256,3),dtype=tf.float32)
tensor_test2 =tf.placeholder(shape=(10,256,256,3),dtype=tf.float32)
print("tensor_test1.shape =",tensor_test1.shape)
print("tensor_test1.shape.is_fully_defined() = ",tensor_test1.shape.is_fully_defined())
print("\ntensor_test2.shape =",tensor_test2.shape)
print("tensor_test2.shape.is_fully_defined() = ",tensor_test2.shape.is_fully_defined())
结果如下:
tensor_test1.shape = (?, 256, 256, 3)
tensor_test1.shape.is_fully_defined() = False
tensor_test2.shape = (10, 256, 256, 3)
tensor_test2.shape.is_fully_defined() = True