def handle_offsize(self, batch_size): if self.activation_offsize == None: split_axis = (2 if self.config['parallelism'] == 'data' else -1) self.activation_offsize = gpu.empty((batch_size, self.unitcount), split_axis) self.out_offsize = gpu.empty((batch_size, self.unitcount), split_axis) self.error_offsize = gpu.empty((batch_size, self.unitcount), split_axis) self.bias_ones_offsize = gpu.zeros((batch_size, 1), split_axis) + 1 swap(self.activation, self.activation_offsize) swap(self.out, self.out_offsize) swap(self.error, self.error_offsize) swap(self.bias_ones, self.bias_ones_offsize) elif self.activation_offsize.shape[2] != batch_size: del self.activation del self.out del self.error del self.bias_ones self.create_buffers(batch_size) else: swap(self.activation, self.activation_offsize) swap(self.out, self.out_offsize) swap(self.error, self.error_offsize) swap(self.bias_ones, self.bias_ones_offsize)
def handle_offsize(self, batch_size): if self.activation_offsize == None: split_axis = (2 if self.config['parallelism'] == 'data' else -1) self.activation_offsize = gpu.empty((batch_size,self.unitcount),split_axis) self.out_offsize = gpu.empty((batch_size,self.unitcount),split_axis) self.error_offsize = gpu.empty((batch_size,self.unitcount),split_axis) self.bias_ones_offsize = gpu.zeros((batch_size,1),split_axis)+1 swap(self.activation, self.activation_offsize) swap(self.out, self.out_offsize) swap(self.error, self.error_offsize) swap(self.bias_ones, self.bias_ones_offsize) elif self.activation_offsize.shape[2] != batch_size: del self.activation del self.out del self.error del self.bias_ones self.create_buffers(batch_size) else: swap(self.activation, self.activation_offsize) swap(self.out, self.out_offsize) swap(self.error, self.error_offsize) swap(self.bias_ones, self.bias_ones_offsize)
def create_buffers(self, batch_size): self.activation = gpu.empty((batch_size,self.unitcount)) self.out = gpu.empty((batch_size,self.unitcount)) self.error = gpu.empty((batch_size,self.unitcount)) self.bias_ones = gpu.ones((batch_size,1))
def normal(mean, std, shape): A = gpu.empty(shape) randomize_gaussian(A, mean, std) return A
def randn(d0, d1): A = gpu.empty((d0, d1)) randomize_gaussian(A, 0, 1) return A
def rand(d0, d1): A = gpu.empty((d0, d1)) randomize_uniform(A) return A
def create_buffers(self, batch_size): self.activation = gpu.empty((batch_size, self.unitcount)) self.out = gpu.empty((batch_size, self.unitcount)) self.error = gpu.empty((batch_size, self.unitcount)) self.bias_ones = gpu.ones((batch_size, 1))
def normal(mean, std, shape): A = gpu.empty(shape) randomize_gaussian(A,mean,std) return A
def randn(d0, d1): A = gpu.empty((d0,d1)) randomize_gaussian(A,0,1) return A
def rand(d0, d1): A = gpu.empty((d0,d1)) randomize_uniform(A) return A