def ascontiguousarray(a): if not a.transposed: return a out = cudarray.empty_like(a) n, m = a.shape array_ops._transpose(a._data, m, n, out._data) return out
def batches(self): x1 = ca.empty(self.x_shape, dtype=self.x.dtype) x2 = ca.empty_like(x1) for start, stop in self._batch_slices(): if stop > start: x1_np = self.x[start:stop] x2_np = self.x2[start:stop] else: x1_np = np.concatenate((self.x[start:], self.x[:stop])) x2_np = np.concatenate((self.x[start:], self.x[:stop])) ca.copyto(x1, x1_np) ca.copyto(x2, x2_np) yield x1, x2
def batches(self): x1 = ca.empty(self.x_shape, dtype=self.x.dtype) x2 = ca.empty_like(x1) y = ca.empty(self.y_shape, dtype=self.y.dtype) for start, stop in self._batch_slices(): if stop > start: x1_np = self.x[start:stop] x2_np = self.x2[start:stop] y_np = self.y[start:stop] else: x1_np = np.concatenate((self.x[start:], self.x[:stop])) x2_np = np.concatenate((self.x[start:], self.x[:stop])) y_np = np.concatenate((self.y[start:], self.y[:stop])) ca.copyto(x1, x1_np) ca.copyto(x2, x2_np) ca.copyto(y, y_np) yield {'x1': x1, 'x2': x2, 'y': y}
def grad_array(self): ''' Returns the gradient array. ''' if self._grad is None: self._grad = ca.empty_like(self.array) return self._grad
def grad_array(self): ''' Returns the gradient array. ''' if self._tmp_grad_array is None: self._tmp_grad_array = ca.empty_like(self.array) return self._tmp_grad_array