(
self,
)
| 177 | class PerGroupInitializerTest(TestCase): |
| 178 | # pylint: disable-next=no-self-use |
| 179 | def test_single_group( |
| 180 | self, |
| 181 | ): |
| 182 | init_cfg = WeightInitializer.default_config() |
| 183 | init = init_cfg.instantiate() |
| 184 | per_group_init = ( |
| 185 | PerGroupInitializer.default_config() |
| 186 | .set( |
| 187 | initializer=init_cfg, |
| 188 | num_groups=1, |
| 189 | ) |
| 190 | .instantiate() |
| 191 | ) |
| 192 | |
| 193 | shape = [3, 3, 4, 6] |
| 194 | |
| 195 | prng_key = jax.random.PRNGKey(123) |
| 196 | init_args = dict( |
| 197 | prng_key=prng_key, |
| 198 | shape=shape, |
| 199 | dtype=jnp.float32, |
| 200 | axes=FanAxes(in_axis=-2, out_axis=-1), |
| 201 | ) |
| 202 | weight_standard_init = init.initialize( |
| 203 | "weight", |
| 204 | **init_args, |
| 205 | ) |
| 206 | weight_per_group_init = per_group_init.initialize( |
| 207 | "weight", |
| 208 | **init_args, |
| 209 | ) |
| 210 | |
| 211 | # no difference when using num_groups=1 |
| 212 | assert_allclose(weight_standard_init, weight_per_group_init) |
| 213 | |
| 214 | # pylint: disable-next=no-self-use |
| 215 | def test_constant_init( |
nothing calls this directly
no test coverage detected