def _getHe2015(self, shape):
#http://cs231n.github.io/neural-networks-2/
if len(shape)==1:
return np.random.normal(0,self.params['init_weight'],shape).astype(config.floatX)
initializer = 'uniform'
if self.params['nonlinearity']=='relu':
K = np.sqrt(2./float((1+self.params['leaky_param']**2)*(shape[0])))
else:
K = np.sqrt(1./float(shape[0]))
if initializer=='uniform':
return np.random.uniform(-K,K,shape).astype(config.floatX)
elif initializer=='normal':
return np.random.normal(0,K,shape).astype(config.floatX)
else:
assert False,'Invalid initializer in _getXavierWeight'
评论列表
文章目录