Function to reshape the vector by the number of dimensions of x. E.g. x (bs, c, h, w), v (bs) -> v (bs, 1, 1, 1). Args: x : Tensor, shape (bs, *dim) v : FloatTensor, shape (bs) Returns: vec : Tensor, shape (bs, number of x dimensions)
(v, x)
| 105 | |
| 106 | |
| 107 | def pad_vector_like_x(v, x): |
| 108 | """ |
| 109 | Function to reshape the vector by the number of dimensions |
| 110 | of x. E.g. x (bs, c, h, w), v (bs) -> v (bs, 1, 1, 1). |
| 111 | Args: |
| 112 | x : Tensor, shape (bs, *dim) |
| 113 | v : FloatTensor, shape (bs) |
| 114 | Returns: |
| 115 | vec : Tensor, shape (bs, number of x dimensions) |
| 116 | """ |
| 117 | if isinstance(v, float): |
| 118 | return v |
| 119 | return v.reshape(-1, *([1] * (x.ndim - 1))) |
| 120 | |
| 121 | |
| 122 | def per_sample_min_max_normalization(x): |
no outgoing calls
no test coverage detected