MCPcopy
hub / github.com/google-deepmind/gemma / init

Method init

gemma/gm/nn/_transformer_like.py:88–115  ·  view source on GitHub ↗

Initializes a module method with variables and returns modified variables. ``init`` takes as first argument either a single ``PRNGKey``, or a dictionary mapping variable collections names to their ``PRNGKeys``, and will call ``method`` (which is the module's ``__call__`` function by

(
      self,
      rngs: PRNGKey | RNGSequences,
      *args,
      method: Callable[..., Any] | str | None = None,
      mutable: CollectionFilter = DenyList('intermediates'),
      capture_intermediates: (
          bool | Callable[[flax.linen.Module, str], bool]
      ) = False,
      **kwargs,
  )

Source from the content-addressed store, hash-verified

86 INFO: ClassVar[ModelInfo]
87
88 def init(
89 self,
90 rngs: PRNGKey | RNGSequences,
91 *args,
92 method: Callable[..., Any] | str | None = None,
93 mutable: CollectionFilter = DenyList('intermediates'),
94 capture_intermediates: (
95 bool | Callable[[flax.linen.Module, str], bool]
96 ) = False,
97 **kwargs,
98 ) -> FrozenVariableDict | dict[str, Any]:
99 """Initializes a module method with variables and returns modified variables.
100
101 ``init`` takes as first argument either a single ``PRNGKey``, or a
102 dictionary mapping variable collections names to their ``PRNGKeys``, and
103 will call ``method`` (which is the module's ``__call__`` function by
104 default) passing ``*args`` and ``**kwargs``, and returns
105 a dictionary of initialized variables.
106
107 Args:
108 rngs: The PRNGKey or dictionary of PRNGKeys.
109 *args: Positional arguments to pass to the method.
110 method: The module method to initialize. Defaults to `__call__`.
111 mutable: A filter for which variable collections are mutable.
112 capture_intermediates: Whether to capture intermediate values.
113 **kwargs: Keyword arguments to pass to the method.
114 """
115 ...
116
117 @typechecked
118 @abc.abstractmethod

Callers 15

test_cache_helperFunction · 0.80
_init_and_applyFunction · 0.80
_get_attn_outputFunction · 0.80
test_sliding_windowFunction · 0.80
test_ffw_gradFunction · 0.80
test_blockFunction · 0.80
test_rmsnormFunction · 0.80
_get_attn_outputFunction · 0.80
test_sliding_windowFunction · 0.80

Calls

no outgoing calls

Tested by 15

test_cache_helperFunction · 0.64
_init_and_applyFunction · 0.64
_get_attn_outputFunction · 0.64
test_sliding_windowFunction · 0.64
test_ffw_gradFunction · 0.64
test_blockFunction · 0.64
test_rmsnormFunction · 0.64
_get_attn_outputFunction · 0.64
test_sliding_windowFunction · 0.64