【问题标题】:Tensorflow tf.reshape: None / -1, is it the same?Tensorflow tf.reshape: None / -1,是一样的吗?
【发布时间】:2018-11-28 17:31:03
【问题描述】:

我只是对 tensorflow reshape 函数有一个简短的问题。 在 tensorflow 中,您可以使用 shape = (None, shape1, shape2, .. ) 初始化张量占位符的形状。 现在我查看了 reshape 函数,他们使用 -1 进行新的 reshape,

例如new_tensor = tf.reshape(old_tensor, shape = (-1, shape1, shape2, ..))

-1 是否等同于 None ?如果不是,这两者有什么区别?

【问题讨论】:

    标签: tensorflow reshape


    【解决方案1】:

    不,它们不相等。

    当您使用None 作为占位符时,这意味着维度将在运行时定义(通常是批量大小)。

    -1 in reshape 表示如果(数据的总大小为 s_0xs_1xs_2...)-1 将自动推断 s_0,我认为这与 numpy 的行为相同。你不能在 reshape 中使用 None 。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-07-04
      • 1970-01-01
      • 1970-01-01
      • 2017-10-28
      • 1970-01-01
      • 2019-09-11
      • 1970-01-01
      • 2017-02-01
      相关资源
      最近更新 更多