예제 #1
0
파일: mlp.py 프로젝트: 0rchard/CUV
  def delta_outputSoftMax(self, calculated, correct):
    derivative = calculated.copy()
    cp.apply_scalar_functor(derivative,  cp.scalar_functor.EXP)
    sums = cp.dev_tensor_float(calculated.shape[1])
    cp.fill(sums,0)
    cp.reduce_to_row(sums, derivative, cp.reduce_functor.ADD)
    cp.apply_scalar_functor(sums,cp.scalar_functor.ADD,0.1/derivative.shape[0])
    rv = cp.transposed_view(derivative)
    cp.matrix_divide_col(rv,sums)

    cp.apply_binary_functor(derivative,  correct,  cp.binary_functor.AXPBY, -1.,1.)
    sums.dealloc()

    return derivative
예제 #2
0
파일: mlp.py 프로젝트: stjordanis/CUV
    def delta_outputSoftMax(self, calculated, correct):
        derivative = calculated.copy()
        cp.apply_scalar_functor(derivative, cp.scalar_functor.EXP)
        sums = cp.dev_tensor_float(calculated.shape[1])
        cp.fill(sums, 0)
        cp.reduce_to_row(sums, derivative, cp.reduce_functor.ADD)
        cp.apply_scalar_functor(sums, cp.scalar_functor.ADD,
                                0.1 / derivative.shape[0])
        rv = cp.transposed_view(derivative)
        cp.matrix_divide_col(rv, sums)

        cp.apply_binary_functor(derivative, correct, cp.binary_functor.AXPBY,
                                -1., 1.)
        sums.dealloc()

        return derivative
예제 #3
0
 def normalize_minmax(self,batch):
     """ normalize by subtracting min and dividing by range"""
     cp.matrix_plus_col(batch,self.negative_min)
     cp.matrix_divide_col(batch,self.range)
예제 #4
0
 def normalize_zmuv(self,batch):
     """ Zero Mean, Unit Variance based on recorded statistics """
     cp.matrix_plus_col(batch,self.negative_mean)
     cp.matrix_divide_col(batch,self.std)
예제 #5
0
 def normalize_minmax(self, batch):
     """ normalize by subtracting min and dividing by range"""
     cp.matrix_plus_col(batch, self.negative_min)
     cp.matrix_divide_col(batch, self.range)
예제 #6
0
 def normalize_zmuv(self, batch):
     """ Zero Mean, Unit Variance based on recorded statistics """
     cp.matrix_plus_col(batch, self.negative_mean)
     cp.matrix_divide_col(batch, self.std)