【问题标题】:Convert an array of 3D tensors to single 4D tensor将 3D 张量数组转换为单个 4D 张量
【发布时间】:2023-02-15 16:02:31
【问题描述】:

我正在尝试将一组 3D 张量(图像)转换为单个 4D 张量,因此我可以将它们作为值传递给 model.fit,它似乎不接受 Tensor3D 数组。

这个想法是

4dTensor = tf.tensor4d(batch)

我实际上使用的是 javascript,但 python 或 js 解决方案可能会起作用,因为 Tensorflow API 是相似的。

这个程序的错误是:

Argument of type 'Tensor4D' is not assignable to parameter of type 'Tensor3D[]'.
  Type 'Tensor<Rank.R4>' is missing the following properties from type 'Tensor3D[]': length, pop, push, join, and 26 more.ts(2345)

【问题讨论】:

    标签: python tensorflow


    【解决方案1】:

    你可能想使用tf.stack()

    4dTensor = tf.stack(batch) 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多