def __init__(self, input_dims, kernel_size): if input_dims < kernel_size: kernel_size = input_dims Layer.__init__(self, "conv1d", input_dims, input_dims - kernel_size + 1) self.kernel_size = kernel_size self.bias = np.random.rand(1) #Just as the weights are shared, so is the bias self.__create_kernel() self.create_weight_matrix_from_kernel()
def __init__(self, input_dims, kernel_width, kernel_height, image_width, image_height): self.image_width = image_width self.image_height = image_height self.kernel = np.random.rand(kernel_height, kernel_width) * 2 - 1 self.bias = np.random.rand(1) self.output_width = self.image_width - kernel_width + 1 self.output_height = self.image_height - kernel_height + 1 Layer.__init__(self, "conv2d", input_dims, self.output_width * self.output_height) self.create_weight_matrix_from_kernel()
def __init__(self, input_dims, error_function=None, target_file_path=None): Layer.__init__(self, "output", input_dims, input_dims) if not target_file_path is None: self.targets = np.genfromtxt(target_file_path, delimiter=',') if len(self.targets.shape) == 1: self.targets = np.reshape(self.targets, (-1, 1)) else: self.targets = None self.error_function = error_function
def __init__(self, input_dims, output_dims): Layer.__init__(self, "sigmoid", input_dims, output_dims)
def __init__(self, input_file_path): self.dataset = np.genfromtxt(input_file_path, delimiter=',') Layer.__init__(self, "input", self.dataset.shape[1], self.dataset.shape[1])
def __init__(self, input_dims, output_dims): Layer.__init__(self, "fullyConnected", input_dims, output_dims) self.__init_weight_matrix() self.bias_vector = np.random.rand(output_dims) * 2 - 1