【发布时间】:2016-08-22 15:44:44
【问题描述】:
我想在 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 构造为描述来使用 y1 作为参数。
但就像我写的那样,它不起作用,因为 tf.zeros_initializer 拒绝获取参数 None。
在 Tensorflow 中将不同拟合流水线化的好方法是什么?
感谢任何 cmets!
【问题讨论】:
标签: machine-learning computer-vision tensorflow