【问题标题】:reshape output or tf.gather(), tensorflow重塑输出或 tf.gather(),张量流
【发布时间】:2016-06-08 09:04:23
【问题描述】:

我在[None, 100, 5, 50] 中有一个来自tf.gather(W,X) 的张量,我想将其重塑为[None, 100, 250]) 但是由于图形的动态方面,使用tf.reshape (even with tf.pack) 会显示Dimension(None) 的错误。 有什么方法可以首先重塑tensor [100,5,50] 的内部,只要图中已知的尺寸,然后使用具有[None, 100, 250]set_shape

【问题讨论】:

    标签: reshape tensorflow


    【解决方案1】:

    tf.reshape() 操作不理解部分形状(即具有None 的一维或多维的那些),因为它们可能是模棱两可的:例如对于部分形状[None, None, 50],可能有许多可能的具体形状。

    不过,tf.reshape() 还允许您将 一个 维度指定为通配符,它​​将自动选择,因此您可以在您的情况下使用它。要指定通配符,请使用-1 作为维度之一:

    input = ...
    print input.get_shape()  ==> [None, 100, 5, 50]
    
    reshaped = tf.reshape(input, [-1, 100, 250])
    

    【讨论】:

      猜你喜欢
      • 2020-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-01
      • 1970-01-01
      • 2016-10-18
      • 2018-10-27
      • 1970-01-01
      相关资源
      最近更新 更多