【问题标题】:tensorflow merge input and outputtensorflow 合并输入输出
【发布时间】: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


    【解决方案1】:

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

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

    它将xy1 沿第三个(基于0)维度连接起来。

    【讨论】:

    • 这正是我想要的,我在 API 中似乎没有找到足够的东西,谢谢!
    猜你喜欢
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 2021-02-24
    • 1970-01-01
    • 1970-01-01
    • 2021-08-05
    • 1970-01-01
    相关资源
    最近更新 更多