예제 #1
0
 def _init_impl(self, scale, out):
     if self.rnd_type == 'uniform':
         random.uniform(-scale, scale, out=out)
     elif self.rnd_type == 'gaussian':
         random.normal(0, scale, out=out)
     else:
         raise ValueError('Unknown random type')
예제 #2
0
파일: myinit.py 프로젝트: happywu/A3C
 def _init_weight(self, _, arr):
     shape = arr.shape
     hw_scale = 1.
     if len(shape) > 2:
         hw_scale = np.prod(shape[2:])
     fan_in, fan_out = shape[1] * hw_scale, shape[0] * hw_scale
     w_bound = np.sqrt(6. / (fan_in + fan_out))
     random.uniform(-w_bound, w_bound, out=arr)
예제 #3
0
 def _init_weight(self, name, arr):
     if name in self._kwargs.keys():
         init_params = self._kwargs[name]
         for (k, v) in init_params.items():
             if k.lower() == "normal":
                 random.normal(0, v, out=arr)
             elif k.lower() == "uniform":
                 random.uniform(-v, v, out=arr)
             elif k.lower() == "orthogonal":
                 raise NotImplementedError("Not support at the moment")
             elif k.lower() == "xavier":
                 xa = Xavier(v[0], v[1], v[2])
                 xa(name, arr)
     else:
         raise NotImplementedError("Not support")
예제 #4
0
 def _init_weight(self, name, arr):
     if name in self._kwargs.keys():
         init_params = self._kwargs[name]
         for (k, v) in init_params.items():
             if k.lower() == "normal":
                 random.normal(0, v, out=arr)
             elif k.lower() == "uniform":
                 random.uniform(-v, v, out=arr)
             elif k.lower() == "orthogonal":
                 raise NotImplementedError("Not support at the moment")
             elif k.lower() == "xavier":
                 xa = Xavier(v[0], v[1], v[2])
                 xa(name, arr)
     else:
         raise NotImplementedError("Not support")
 def _init_weight(self, _, arr):
     random.uniform(0, self.scale, out=arr)