Ejemplo n.º 1
0
    def __init__(self, kernel_sizes, in_channels, out_channels):
        super(Conv2D, self).__init__()

        self.in_channels = in_channels
        self.out_channels = out_channels

        self.kernels = [
            Variable.random(*kernel_sizes) for _ in range(out_channels)
        ]
        self.biases = [
            Variable.random(*kernel_sizes) for _ in range(out_channels)
        ]
        self._parameters.update(
            {f"kernel_{i}": kernel
             for i, kernel in enumerate(self.kernels)})
        self._parameters.update(
            {f"bias_{i}": bias
             for i, bias in enumerate(self.biases)})
Ejemplo n.º 2
0
 def __init__(self, input_size, output_size):
     super(Dense, self).__init__()
     self.weights = Variable.random(input_size, output_size)
     self.bias = Variable.random(output_size, sign='+')
     self._parameters = {'weights': self.weights, 'bias': self.bias}