创建一个占位符,其形状是另一个形状的函数
Creating a placeholder having a shape that is a function of another shape
假设我们有一个tensorflow占位符如下:
x = tf.placeholder(tf.float32, (2, 2, 3 ..., 1))
我想创建另一个张量 y
除了第一维和第二维外,其形状与 x
相同,它们是 x
.[=17= 的三倍]
y = tf.placeholder(tf.float32, (6, 6, 3, ..., 1))
x
的形状没有预定义,所以我想做的是如下所示:
y = tf.placeholder(tf.float32, (x.shape[0]* 3, x.shape[1] * 3, remaining_are_the_same_as_x_shape))
你能告诉我如何在 tensorflow 中做到这一点吗?
这个呢?
x = tf.placeholder(tf.float32, (2, 2, 3 , 1))
shape = x.get_shape().as_list()
shape[0] = shape[0] * 3
shape[1] = shape[1] * 3
y = tf.placeholder(tf.float32, shape=shape)
shape = y.get_shape().as_list()
print(shape)
[6, 6, 3, 1]
假设我们有一个tensorflow占位符如下:
x = tf.placeholder(tf.float32, (2, 2, 3 ..., 1))
我想创建另一个张量 y
除了第一维和第二维外,其形状与 x
相同,它们是 x
.[=17= 的三倍]
y = tf.placeholder(tf.float32, (6, 6, 3, ..., 1))
x
的形状没有预定义,所以我想做的是如下所示:
y = tf.placeholder(tf.float32, (x.shape[0]* 3, x.shape[1] * 3, remaining_are_the_same_as_x_shape))
你能告诉我如何在 tensorflow 中做到这一点吗?
这个呢?
x = tf.placeholder(tf.float32, (2, 2, 3 , 1))
shape = x.get_shape().as_list()
shape[0] = shape[0] * 3
shape[1] = shape[1] * 3
y = tf.placeholder(tf.float32, shape=shape)
shape = y.get_shape().as_list()
print(shape)
[6, 6, 3, 1]