MCPcopy
hub / github.com/open-mmlab/OpenPCDet / listify

Function listify

tools/train_utils/optimization/fastai_optim.py:80–91  ·  view source on GitHub ↗

Make `p` listy and the same length as `q`.

(p=None, q=None)

Source from the content-addressed store, hash-verified

78
79
80def listify(p=None, q=None):
81 "Make `p` listy and the same length as `q`."
82 if p is None:
83 p = []
84 elif isinstance(p, str):
85 p = [p]
86 elif not isinstance(p, Iterable):
87 p = [p]
88 n = q if type(q) == int else len(p) if q is None else len(q)
89 if len(p) == 1: p = p * n
90 assert len(p) == n, f'List len mismatch ({len(p)} vs {n})'
91 return list(p)
92
93
94def trainable_params(m: nn.Module):

Callers 6

createMethod · 0.85
stepMethod · 0.85
lrMethod · 0.85
momMethod · 0.85
betaMethod · 0.85
wdMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected