MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / parameters

Method parameters

imperative/python/megengine/module/module.py:210–231  ·  view source on GitHub ↗

r"""Returns an iterable for the :class:`~.Parameter` of the module. Args: recursive: If ``True``, returns all :class:`~.Parameter` within this module, else only returns :class:`~.Parameter` that are direct attributes of this module.

(self, recursive: bool = True, **kwargs)

Source from the content-addressed store, hash-verified

208 )
209
210 def parameters(self, recursive: bool = True, **kwargs) -> Iterable[Parameter]:
211 r"""Returns an iterable for the :class:`~.Parameter` of the module.
212
213 Args:
214 recursive: If ``True``, returns all :class:`~.Parameter` within this
215 module, else only returns :class:`~.Parameter` that are direct attributes
216 of this module.
217 """
218
219 if "requires_grad" in kwargs:
220 del kwargs["requires_grad"]
221 logger.warning(
222 "Tensor currently has no requires_grad attribute "
223 "so requires_grad argument is ignored here"
224 )
225
226 def predicate(obj) -> bool:
227 return _is_parameter(obj)
228
229 yield from self._flatten(
230 with_key=False, predicate=predicate, recursive=recursive, **kwargs
231 )
232
233 def named_parameters(
234 self, prefix: Optional[str] = None, recursive: bool = True, **kwargs

Callers 15

zero_gradMethod · 0.95
test_format_remainedFunction · 0.95
reset_parametersMethod · 0.80
reset_parametersMethod · 0.80
__init__Method · 0.80
updateMethod · 0.80
flatten_inputsMethod · 0.80
test_advance_indexingFunction · 0.80
update_modelFunction · 0.80
workerFunction · 0.80

Calls 1

_flattenMethod · 0.95

Tested by 15

test_format_remainedFunction · 0.76
test_advance_indexingFunction · 0.64
update_modelFunction · 0.64
workerFunction · 0.64
test_save_loadFunction · 0.64
run_dtr_resnet1202Function · 0.64
workerFunction · 0.64
test_xornet_trace_dumpFunction · 0.64
test_ViTmode_trace_trainFunction · 0.64
runnerFunction · 0.64