【问题标题】:convolutional layer - trainable weights TensorFlow2卷积层 - 可训练的权重 TensorFlow2
【发布时间】:2021-06-29 12:34:06
【问题描述】:

我正在使用 TF2.5 和 Python3.8,其中 conv 层定义为:

Conv2D(
    filters = 64, kernel_size = (3, 3),
    activation='relu', kernel_initializer = tf.initializers.GlorotNormal(),
    strides = (1, 1), padding = 'same',
)

使用一批 60 个 CIFAR-10 数据集作为输入:

x.shape
# TensorShape([60, 32, 32, 3])

该层的输出体积保留了空间宽度和高度(32、32),并有 64 个过滤器/内核映射作为批处理应用于 60 个图像-

conv1(x).shape
# TensorShape([60, 32, 32, 64])

我理解这个输出。

你能解释一下输出:

conv1.trainable_weights[0].shape
# TensorShape([3, 3, 3, 64])

【问题讨论】:

    标签: python-3.x tensorflow2.0


    【解决方案1】:

    这是用于计算卷积层中可训练参数数量的公式 = [{(m x n x d) + 1} x k]

    在哪里, m -> 过滤器的宽度; n -> 过滤器的高度; d -> 输入音量中的通道数; k -> 当前层中应用的过滤器数量。

    添加 1 作为每个过滤器的偏差。但在 TF2.X 的情况下,对于 conv 层,偏置项设置为 False。因此,它不会出现在公式中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-08
      • 1970-01-01
      • 1970-01-01
      • 2021-09-11
      • 2020-12-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多