Ejemplo n.º 1
0
Archivo: mlp.py Proyecto: 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
Ejemplo n.º 2
0
    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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)