【问题标题】:Set bias in CNN在 CNN 中设置偏差
【发布时间】:2016-09-25 16:08:13
【问题描述】:

我有两个用于 CNN 的大量 numpy 权重和偏差数组。我可以为每一层设置权重(使用set_weights),但我看不到为每一层设置偏差的方法。我该怎么做?

【问题讨论】:

    标签: python deep-learning keras


    【解决方案1】:

    您可以使用layer.set_weights(weights) 来执行此操作。来自文档:

    weights: a list of Numpy arrays. The number
             of arrays and their shape must match
             number of the dimensions of the weights
             of the layer (i.e. it should match the
             output of `get_weights`).
    

    您不只是将过滤器的权重放在那里,而是将层具有的 each 参数放在那里。您必须输入权重的顺序取决于layer.weights。您可以查看代码或通过执行类似的操作打印层权重的名称

     print([p.name for p in layer.weights])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-04
      相关资源
      最近更新 更多