Expand the tensor `v` to the dim `dims`. Args: `v`: a PyTorch tensor with shape [N]. `dim`: a `int`. Returns: a PyTorch tensor with shape [N, 1, 1, ..., 1] and the total dimension is `dims`.
(v, dims)
| 1143 | |
| 1144 | |
| 1145 | def expand_dims(v, dims): |
| 1146 | """ |
| 1147 | Expand the tensor `v` to the dim `dims`. |
| 1148 | Args: |
| 1149 | `v`: a PyTorch tensor with shape [N]. |
| 1150 | `dim`: a `int`. |
| 1151 | Returns: |
| 1152 | a PyTorch tensor with shape [N, 1, 1, ..., 1] and the total dimension is `dims`. |
| 1153 | """ |
| 1154 | return v[(...,) + (None,) * (dims - 1)] |
no outgoing calls
no test coverage detected