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

Method test_none_fan

axlearn/common/param_init_test.py:160–174  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

158class WeightInitializerTest(TestCase):
159 # pylint: disable-next=no-self-use
160 def test_none_fan(self):
161 scale = 1.0
162 init: WeightInitializer = (
163 WeightInitializer.default_config()
164 .set(fan=None, scale=scale, distribution="uniform")
165 .instantiate()
166 )
167 weight_shape = [100, 100]
168 weight = init.initialize(
169 "weight", prng_key=jax.random.PRNGKey(1), shape=weight_shape, dtype=jnp.float32
170 )
171 std_err = 1 / (12 * np.sqrt(np.prod(weight_shape))) * scale * 2
172 self.assertBetween(np.mean(weight), 0.0 - 6 * std_err, 0.0 + 6 * std_err)
173 assert_allclose(jnp.min(weight), -scale, rtol=1e-4)
174 assert_allclose(jnp.max(weight), scale, rtol=1e-4)
175
176
177class PerGroupInitializerTest(TestCase):

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected