(a, b, include=(), exclude=())
| 19 | |
| 20 | |
| 21 | def copy_attr(a, b, include=(), exclude=()): |
| 22 | # Copy attributes from b to a, options to only include [...] and to exclude [...] |
| 23 | for k, v in b.__dict__.items(): |
| 24 | if (len(include) and k not in include) or k.startswith("_") or k in exclude: |
| 25 | continue |
| 26 | else: |
| 27 | setattr(a, k, v) |
| 28 | |
| 29 | |
| 30 | class ModelEMA: |