我想在连续的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
通过使用参数W_conv b_conv来最小化首先最小化cross_entropy(y1 y1_),然后通过将im_y1构造为describe来使用y1作为参数。
但是就像我写的那样,它起作用了,因为tf.zeros_initializer拒绝接受参数None。
在Tensorflow中,在同一模型中管道不同拟合的好方法是什么?
感谢任何评论!
答案 0 :(得分:1)
将示例的最后三行替换为:
im_y1 = tf.concat(3, [x, y1])
它将x
和y1
连接在第3维(0)维度上。