| Total Complexity | 5 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| 1 | import theano.tensor as T |
||
| 5 | class Concatenate(NeuralLayer): |
||
| 6 | """ |
||
| 7 | Concatenate two tensors. |
||
| 8 | They should have identical dimensions except the last one. |
||
| 9 | """ |
||
| 10 | |||
| 11 | def __init__(self, axis=2): |
||
| 12 | """ |
||
| 13 | :type layer1: NeuralLayer |
||
| 14 | :type layer2: NeuralLayer |
||
| 15 | """ |
||
| 16 | super(Concatenate, self).__init__("concate") |
||
| 17 | self.axis = axis |
||
| 18 | if axis < 0: |
||
| 19 | raise Exception("There are some bugs in T.concatenate, that axis can not lower than 0") |
||
| 20 | |||
| 21 | def prepare(self): |
||
| 22 | self.output_dim = sum(self.input_dims) |
||
| 23 | |||
| 24 | def output(self, *xs): |
||
| 25 | return T.concatenate(xs, axis=self.axis) |
||
| 26 | |||
| 27 | def test_output(self, *xs): |
||
| 28 | return T.concatenate(xs, axis=self.axis) |
||
| 29 |