【问题标题】:can I use conv2d with input dimension not fixed?我可以在输入维度不固定的情况下使用 conv2d 吗?
【发布时间】:2022-01-19 10:56:03
【问题描述】:

我是 tensorflow 的新手,我有一个问题:我可以在我的 conv2d 中放入一个形状不固定的输入吗? 输入.形状 =(?, 1568) 当我训练我的神经网络时,我收到以下信息: raise ValueError(f'Input {input_index} of layer "{layer_name}" ' ValueError: Input 0 of layer "conv2d" is incompatible with the layer: expected min_ndim=4, found ndim=2. Full shape received: (Dimension(None), Dimension(1568)) 我的 con2d 层是这样的: x = Conv2D(32, (3,3), padding="same",input_shape=input_shape[1:])(inputs)

【问题讨论】:

  • 问题不在于固定维度,对于Conv2D,您的数据不是图像,它应该有四个维度:(样本、宽度、高度、通道)。
  • 输入形状?
  • 是的,输入的形状
  • inputs.shape =(?, 1568)

标签: python tensorflow keras conv-neural-network


【解决方案1】:

我通过使用tf.expand_dims解决了这个问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-25
    • 1970-01-01
    相关资源
    最近更新 更多