def logreg_cost(self, label, output): if self.cost.shape[0] != self.batch_size: self.cost = gpuarray.zeros((self.batch_size, 1), dtype=np.float32) maxid = gpuarray.zeros((self.batch_size, 1), dtype=np.float32) find_col_max_id(maxid, output) self.batchCorrect = same_reduce(label , maxid) logreg_cost_col_reduce(output, label, self.cost)
def logreg_cost_multiview(self, label, output, num_view): unit = self.batch_size / num_view if self.cost.shape[0] != unit: self.cost = gpuarray.zeros((unit, 1), dtype = np.float32) maxid = gpuarray.zeros((self.batch_size, 1), dtype = np.float32) find_col_max_id(maxid, output) self.batchCorrect = same_reduce_multiview(label, maxid, num_view) tmp = gpuarray.zeros((output.shape[0], unit), dtype = np.float32) gpu_partial_copy_to(output, tmp, 0, output.shape[0], 0, unit) logreg_cost_col_reduce(tmp, label, self.cost)