我是 tensorflow.keras 的初学者,我想知道如何创建一个特定形状的恒定零张量。
例如:
zeros = tf.keras.backend.zeros((someTensor.shape[0], someTensor.shape[1], someTensor.shape[2], channels))
concat = tf.kerasbackend.concatenate([someTensor, zeros], axis=3)
tf.keras.backend.zeros 操作失败,原因如下:
ValueError: Cannot convert a partially known TensorShape to a Tensor
我想那是因为在图形构建过程中批量大小是未知的。当我当时不知道批量大小时,如何创建 ZeroTensor 或任何其他常量张量?还是我可以指定某种未知(?)值?