| 42 | |
| 43 | |
| 44 | class MyModule(nn.Module): |
| 45 | |
| 46 | @nn.compact |
| 47 | def __call__(self, x): |
| 48 | # Call a same model twice |
| 49 | model = nn.Dense(1) |
| 50 | y0 = nn.Dropout(0.5, deterministic=False)(x) |
| 51 | y1 = model(x) |
| 52 | y2 = model(x) |
| 53 | |
| 54 | # Call another model |
| 55 | y3 = nn.Dense(2)(x) |
| 56 | return { |
| 57 | 'y0': y0, |
| 58 | 'y1': y1, |
| 59 | 'y2': y2, |
| 60 | 'y3': y3, |
| 61 | } |
| 62 | |
| 63 | |
| 64 | def test_module(): |
no outgoing calls