Appends dimensions to the end of a tensor until it has target_dims dimensions.
(x, target_dims)
| 276 | |
| 277 | |
| 278 | def append_dims(x, target_dims): |
| 279 | """Appends dimensions to the end of a tensor until it has target_dims dimensions.""" |
| 280 | dims_to_append = target_dims - x.ndim |
| 281 | if dims_to_append < 0: |
| 282 | raise ValueError(f"input has {x.ndim} dims but target_dims is {target_dims}, which is less") |
| 283 | return x[(...,) + (None,) * dims_to_append] |
| 284 | |
| 285 | |
| 286 | def load_model_from_config(config, ckpt, verbose=True, freeze=True): |
no outgoing calls
no test coverage detected