MCPcopy
hub / github.com/nlpodyssey/spago / ForEachParam

Function ForEachParam

nn/model.go:75–81  ·  view source on GitHub ↗

ForEachParam iterate all the parameters of a model also exploring the sub-parameters recursively.

(m Model, fn func(param *Param))

Source from the content-addressed store, hash-verified

73
74// ForEachParam iterate all the parameters of a model also exploring the sub-parameters recursively.
75func ForEachParam(m Model, fn func(param *Param)) {
76 paramsTraversal{
77 paramsFunc: fn,
78 modelsFunc: nil,
79 exploreSubModels: true,
80 }.walk(m)
81}
82
83// ForEachParamStrict iterate all the parameters of a model without exploring the sub-models.
84func ForEachParamStrict(m Model, fn func(param *Param)) {

Callers 5

InitMethod · 0.92
testModelConcatForwardFunction · 0.92
TestModel_TraverseParamsFunction · 0.92
ZeroGradFunction · 0.85
TestForEachParamFunction · 0.85

Calls 1

walkMethod · 0.80

Tested by 3

testModelConcatForwardFunction · 0.74
TestModel_TraverseParamsFunction · 0.74
TestForEachParamFunction · 0.68