| Total Complexity | 3 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| 1 | #!/usr/bin/env python |
||
| 7 | class Maxout(NeuralLayer): |
||
| 8 | """ |
||
| 9 | Maxout activation unit. |
||
| 10 | - http://arxiv.org/pdf/1302.4389.pdf |
||
| 11 | """ |
||
| 12 | def __init__(self, output_dim, num_pieces=4, init=None): |
||
| 13 | """ |
||
| 14 | :param num_pieces: pieces of sub maps |
||
| 15 | """ |
||
| 16 | super(Maxout, self).__init__("maxout") |
||
| 17 | self.num_pieces = num_pieces |
||
| 18 | self.output_dim = output_dim |
||
| 19 | self.init = init |
||
| 20 | |||
| 21 | |||
| 22 | def prepare(self): |
||
| 23 | self.W = self.create_weight(shape=(self.num_pieces, self.input_dim, self.output_dim), |
||
| 24 | initializer=self.init, suffix="maxout") |
||
| 25 | self.B = self.create_bias(shape=(self.num_pieces, self.output_dim), suffix="maxout") |
||
| 26 | self.register_parameters(self.W, self.B) |
||
| 27 | |||
| 28 | |||
| 29 | def output(self, x): |
||
| 30 | return T.max(T.dot(x, self.W) + self.B, axis=1) |