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
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
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)
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)
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)
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)