MCPcopy Create free account
hub / github.com/apple/axlearn / test_single_group

Method test_single_group

axlearn/common/param_init_test.py:179–212  ·  view source on GitHub ↗
(
        self,
    )

Source from the content-addressed store, hash-verified

177class 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(

Callers

nothing calls this directly

Calls 6

FanAxesClass · 0.90
assert_allcloseFunction · 0.90
default_configMethod · 0.45
instantiateMethod · 0.45
setMethod · 0.45
initializeMethod · 0.45

Tested by

no test coverage detected