【论文复现】如何快速初始化CNN参数?
Created by: kgkzhiwen
假设我在网络里定义了一堆CNN,现在我需要为它们设定kaiming初始值,我知道我可以在每一行定义中加入类似 params_attr=fluid.initalizer.MSRA() 来实现目的。当CCN层太多的时候,这种方法就很麻烦,而且也不利于后续的改动,比如我要试试xavier初始值,我要一行一行的再改回来。因此我想知道怎么样用代码去跑一个循环来实现设定初始值的目的?
class Test(fluid.dygraph.Layer):
def __init__(self, name_scope):
super(Test, self).__init__(name_scope)
self.convT1=Conv2D(num_channels=100, num_filters=1024, filter_size=4)
self.convT2=Conv2D(num_channels=1024, num_filters=512, filter_size=5)
self.convT3=Conv2D(num_channels=512, num_filters=256, filter_size=5,stride=2,padding=2,output_size=16)
self.convT4=Conv2D(num_channels=256, num_filters=128, filter_size=5,stride=2,padding=2,output_size=32)
self.convT5=Conv2D(num_channels=128, num_filters=1, filter_size=5,padding=4,act='tanh')
......