コード例 #1
0
ファイル: loss.py プロジェクト: EricSchles/deeppy
 def setup_from_shape(self, in_shape):
     batch_size = in_shape[0]
     self.shape = (batch_size,)
     self.array = ca.zeros(self.shape)
     self.grad_array = ca.ones(self.shape)
     self.axis = tuple(range(1, len(in_shape)))
     self.bcast_shape = tuple([batch_size, ] + [1, ]*len(self.axis))
コード例 #2
0
ファイル: test.py プロジェクト: EricSchles/deeppy
 def fun_grad(x):
     ca.random.seed(seed)
     src.array = ca.array(x)
     graph.fprop()
     sink.grad_array = ca.ones(sink.shape, dtype=ca.float_)
     graph.bprop()
     x_grad = np.array(src.grad_array)
     return x_grad
コード例 #3
0
ファイル: test.py プロジェクト: yyc2019/deeppy
 def fun_grad(x):
     ca.random.seed(seed)
     src.array = ca.array(x)
     graph.fprop()
     sink.grad_array = ca.ones(sink.shape, dtype=ca.float_)
     graph.bprop()
     x_grad = np.array(src.grad_array)
     return x_grad
コード例 #4
0
ファイル: loss.py プロジェクト: trb116/pythonanalyzer
 def setup_from_shape(self, in_shape):
     batch_size = in_shape[0]
     self.shape = (batch_size, )
     self.array = ca.zeros(self.shape)
     self.grad_array = ca.ones(self.shape)
     self.axis = tuple(range(1, len(in_shape)))
     self.bcast_shape = tuple([
         batch_size,
     ] + [
         1,
     ] * len(self.axis))
コード例 #5
0
 def setup(self):
     super(BatchNormalization, self).setup()
     if len(self.out_shape) != 2:
         raise ValueError('Only 1D data supported')
     reduced_shape = 1, self.out_shape[1]
     self.running_mean = ca.zeros(reduced_shape)
     self.running_std = ca.ones(reduced_shape)
     self._tmp_batch_centered = ca.zeros(self.out_shape)
     self._tmp_batch_inv_std = ca.zeros(reduced_shape)
     if self.affine:
         self.gamma.setup(reduced_shape)
         self.beta.setup(reduced_shape)
コード例 #6
0
 def setup(self):
     super(BatchNormalization, self).setup()
     reduced_shape = (1,) + self.out_shape[1:]
     if self.running_mean is None:
         self.running_mean = ca.zeros(reduced_shape)
         self.running_std = ca.ones(reduced_shape)
         if self.affine:
             self.gamma.setup(reduced_shape)
             self.beta.setup(reduced_shape)
     else:
         if self.running_mean.shape != reduced_shape:
             raise ValueError('New input shape is not compatible')
     self._tmp_batch_inv_std = ca.zeros(reduced_shape)
     self._tmp_batch_centered = ca.zeros(self.out_shape)
コード例 #7
0
 def setup(self):
     super(BatchNormalization, self).setup()
     reduced_shape = (1, ) + self.out_shape[1:]
     if self.running_mean is None:
         self.running_mean = ca.zeros(reduced_shape)
         self.running_std = ca.ones(reduced_shape)
         if self.affine:
             self.gamma.setup(reduced_shape)
             self.beta.setup(reduced_shape)
     else:
         if self.running_mean.shape != reduced_shape:
             raise ValueError('New input shape is not compatible')
     self._tmp_batch_inv_std = ca.zeros(reduced_shape)
     self._tmp_batch_centered = ca.zeros(self.out_shape)
コード例 #8
0
ファイル: batch_normalization.py プロジェクト: obinsc/deeppy
 def setup(self):
     super(SpatialBatchNormalization, self).setup()
     if len(self.out_shape) != 4:
         raise ValueError('Only 4D data supported')
     reduced_shape = 1, self.out_shape[1], 1, 1
     if self.running_mean is None:
         self.running_mean = ca.zeros(reduced_shape)
         self.running_std = ca.ones(reduced_shape)
         if self.affine:
             self.gamma.setup(reduced_shape)
             self.beta.setup(reduced_shape)
     else:
         if self.running_mean.shape != reduced_shape:
             raise ValueError('New input shape is not compatible')
     self._tmp_batch_inv_std = ca.zeros(reduced_shape)
     self._tmp_batch_centered = ca.zeros(self.out_shape)
コード例 #9
0
 def setup(self):
     super(SpatialBatchNormalization, self).setup()
     if len(self.out_shape) != 4:
         raise ValueError('Only 4D data supported')
     reduced_shape = 1, self.out_shape[1], 1, 1
     if self.running_mean is None:
         self.running_mean = ca.zeros(reduced_shape)
         self.running_std = ca.ones(reduced_shape)
         if self.affine:
             self.gamma.setup(reduced_shape)
             self.beta.setup(reduced_shape)
     else:
         if self.running_mean.shape != reduced_shape:
             raise ValueError('New input shape is not compatible')
     self._tmp_batch_inv_std = ca.zeros(reduced_shape)
     self._tmp_batch_centered = ca.zeros(self.out_shape)
コード例 #10
0
ファイル: fillers.py プロジェクト: Snazz2001/deeppy
 def array(self, shape):
     return ca.ones(shape)*self.c
コード例 #11
0
 def array(self, shape):
     return ca.ones(shape) * self.value
コード例 #12
0
ファイル: loss.py プロジェクト: houxingxing/deeppy
 def setup(self):
     self.out_shape = (self.pred.out_shape[0], 1)
     self.out = ca.empty(self.out_shape)
     self.out_grad = ca.ones(self.out_shape)
コード例 #13
0
 def setup(self):
     self.out_shape = (len(self.mu.out), 1)
     self.out = ca.empty(self.out_shape)
     self.out_grad = ca.ones(self.out_shape)