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

Method default_config

axlearn/common/bert.py:325–348  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

323
324 @classmethod
325 def default_config(cls):
326 cfg: BertModel.Config = super().default_config()
327 # param_init matches original tf implementation. The Hugging Face implementation uses plain
328 # GaussianInitializer which empirically does not work as well (gradients quickly vanish).
329 # https://github.com/google-research/bert/blob/eedf5716ce1268e56f0a50264a88cafad334ac61/modeling.py#L377
330 # https://github.com/huggingface/transformers/blob/aa6cfe9c4b073b2c058a78fc2d26fe3fbe0ad70b/src/transformers/models/bert/modeling_bert.py#L726
331 cfg.param_init = DefaultInitializer.default_config().set(
332 init_by_param_name={
333 PARAM_REGEXP_WEIGHT: WeightInitializer.default_config().set(
334 fan=None,
335 distribution="truncated_normal",
336 scale=0.02,
337 )
338 }
339 )
340 # By default, assume `head` employs tied weights.
341 cfg.head = BertLMHead.default_config().set(
342 inner_head=RedirectToSharedModule.default_config().set(
343 shared_module="shared_token_emb",
344 # Map the method name here so the child can just call forward directly.
345 method_map=dict(forward="attend"),
346 )
347 )
348 return cfg
349
350
351def bert_embedding_config(

Callers 9

ConfigClass · 0.45
ConfigClass · 0.45
ConfigClass · 0.45
ConfigClass · 0.45
ConfigClass · 0.45
bert_embedding_configFunction · 0.45
bert_lm_head_configFunction · 0.45
bert_transformer_configFunction · 0.45
bert_model_configFunction · 0.45

Calls 1

setMethod · 0.45

Tested by

no test coverage detected