张量流合并输入和输出

tensorflow merge input and output

我想在 tensorflow 中连续使用两个模型,以适应第一个并直接将其用于第二个作为输入。但是我没有找到好的方法。我尝试按以下方式进行,

x = tf.placeholder('float', shape=[None, image_size[0] , image_size[1]])

y1_ = tf.placeholder('float', shape=[None, image_size[0] , image_size[1], 1])
y2_ = tf.placeholder('float', shape=[None, image_size[0] , image_size[1],\ 
                                                               labels_count])
image = tf.reshape(x, [-1,image_size[0] , image_size[1],1])
# y1 first output, to fit
W_conv = weight_variable([1, 1, 1, labels_count])
b_conv = bias_variable([labels_count])

y1 = conv2d(image, W_conv) + b_conv

cross_entropy1 = tf.reduce_sum(tf.nn.sigmoid_cross_entropy_with_logits(y1, y1_))
train_step1 =\
tf.train.GradientDescentOptimizer(LEARNING_RATE).minimize(cross_entropy)
# Then use as input the folowing
im_y1 = tf.zeros_initializer([None,image_size[0] , image_size[1],2])
im_y1[:,:,:,0]=x
im_y1[:,:,:,1]=y1

事情是首先最小化 cross_entropy( y1 y1_) 参数 W_conv b_conv 然后通过构造 im_y1 使用 y1 作为参数描述。

但是就像我写的那样,它不起作用,因为 tf.zeros_initializer 拒绝获取参数 None。

在 Tensorflow 的同一模型中流水线化不同拟合的好方法是什么?

感谢任何评论!

将示例的最后三行替换为:

im_y1 = tf.concat(3, [x, y1])

它沿第 3 个(基于 0 的)维度连接 xy1