gpt4 book ai didi

python-3.x - 为什么keras.backend.pool3d要求tensor_in是5维的?

转载 作者:行者123 更新时间:2023-11-30 09:40:16 28 4
gpt4 key购买 nike

我有以下代码

from tensorflow import keras
from keras import backend as K

pool_size = (2,2,2)
strides = (2,2,2)

yt = K.zeros(shape=(10,10,10))

result = keras.backend.pool3d(yt, pool_size, strides, pool_mode="avg")

当我尝试运行代码时,它显示

.. InvalidArgumentError: tensor_in must be 5-dimensional [Op:AvgPool3D] name: AvgPool3D/

我似乎不喜欢 yt 的尺寸。但我想在尺寸为 3x3x3 的 3d 图像中最大池化。另一个维度应该是多少?

最佳答案

  • 批量大小
  • channel

正如 Keras 中的每个类似卷积的操作一样,这些维度都是必需的。

  • 使用“channels_last”(默认):(batch、size1、size2、size3、channels)
  • 使用“channels_first”:(批处理、 channel 、size1、size2、size3)

所以:

yt = K.zeros(shape=(1,10,10,10,1))

关于python-3.x - 为什么keras.backend.pool3d要求tensor_in是5维的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59218360/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com