(self, shape)
| 33 | self.t3 = tensor.Tensor((30, 50, 4, 8)) |
| 34 | |
| 35 | def compute_fan(self, shape): |
| 36 | if len(shape) == 2: |
| 37 | fan_in = shape[0] |
| 38 | fan_out = shape[1] |
| 39 | elif len(shape) in {3, 4, 5}: |
| 40 | fan_in = shape[1] * np.prod(shape[2:]) |
| 41 | fan_out = shape[0] * np.prod(shape[2:]) |
| 42 | else: |
| 43 | fan_in = fan_out = np.sqrt(np.prod(shape)) |
| 44 | |
| 45 | return fan_in, fan_out |
| 46 | |
| 47 | def he_uniform(self, dev): |
| 48 |