示例#1
0
 def bprop(self, grad, input, output, outGrad):
   if self.dropRate > 0.0:
     gpu_copy_to(grad * self.dropMask, grad)
  
   gpu_copy_to(transpose(dot(transpose(grad), self.weight.wt)), outGrad)
   
   self.weight.set_grad(dot(grad, transpose(input)))
   add_row_sum_to_vec(self.bias.grad, grad, alpha=0.0)
示例#2
0
 def bprop(self, grad, input, output, outGrad):
   if self.dropRate > 0.0:
     gpu_copy_to(grad * self.dropMask, grad)
  
   gpu_copy_to(transpose(dot(transpose(grad), self.weight.wt)), outGrad)
   
   self.weight.set_grad(dot(grad, transpose(input)))
   add_row_sum_to_vec(self.bias.grad, grad, alpha=0.0)
示例#3
0
  def fprop(self, input, output, train=TRAIN):
    gpu_copy_to(dot(self.weight.wt, input), output)
    add_vec_to_rows(output, self.bias.wt)

    if train == TEST:
      if self.dropRate > 0.0:
        output *= (1.0 - self.dropRate)
    else:
      if self.dropRate > 0.0:
        self.dropMask = to_gpu(np.random.uniform(0, 1, output.size).astype(np.float32).reshape(output.shape))
        bigger_than_scaler(self.dropMask, self.dropRate)
        gpu_copy_to(output * self.dropMask, output)
    if PFout:
      print_matrix(output, self.name)
示例#4
0
  def fprop(self, input, output, train=TRAIN):
    gpu_copy_to(dot(self.weight.wt, input), output)
    add_vec_to_rows(output, self.bias.wt)

    if train == TEST:
      if self.dropRate > 0.0:
        output *= (1.0 - self.dropRate)
    else:
      if self.dropRate > 0.0:
        self.dropMask = to_gpu(np.random.uniform(0, 1, output.size).astype(np.float32).reshape(output.shape))
        bigger_than_scaler(self.dropMask, self.dropRate)
        gpu_copy_to(output * self.dropMask, output)
    if PFout:
      print_matrix(output, self.name)