| Total Complexity | 5 |
| Total Lines | 15 |
| Duplicated Lines | 0 % |
| 1 | #!/usr/bin/env python |
||
| 7 | class Dropout(NeuralLayer): |
||
| 8 | |||
| 9 | def __init__(self, p): |
||
| 10 | super(Dropout, self).__init__("dropout") |
||
| 11 | self.p = p |
||
| 12 | |||
| 13 | def output(self, x): |
||
| 14 | if self.p > 0: |
||
| 15 | x *= global_theano_rand.binomial(x.shape, p=1-self.p, dtype=FLOATX) |
||
| 16 | return x |
||
| 17 | |||
| 18 | def test_output(self, x): |
||
| 19 | if self.p > 0: |
||
| 20 | x *= (1.0 - self.p) |
||
| 21 | return x |
||
| 22 |