Return a grid of assignments. :param assignments: Vector of integers corresponding to class labels. :param n_sqrt: Square root of no. of assignments. :return: Reshaped square matrix of assignments.
(assignments: Tensor, n_sqrt: int)
| 86 | |
| 87 | |
| 88 | def get_square_assignments(assignments: Tensor, n_sqrt: int) -> Tensor: |
| 89 | # language=rst |
| 90 | """ |
| 91 | Return a grid of assignments. |
| 92 | |
| 93 | :param assignments: Vector of integers corresponding to class labels. |
| 94 | :param n_sqrt: Square root of no. of assignments. |
| 95 | :return: Reshaped square matrix of assignments. |
| 96 | """ |
| 97 | square_assignments = torch.mul(torch.ones(n_sqrt, n_sqrt), -1.0) |
| 98 | for i in range(n_sqrt): |
| 99 | for j in range(n_sqrt): |
| 100 | n = i * n_sqrt + j |
| 101 | |
| 102 | if not n < assignments.size(0): |
| 103 | break |
| 104 | |
| 105 | square_assignments[i : (i + 1), (j % n_sqrt) : ((j % n_sqrt) + 1)] = ( |
| 106 | assignments[n] |
| 107 | ) |
| 108 | |
| 109 | return square_assignments |
| 110 | |
| 111 | |
| 112 | def reshape_locally_connected_weights( |
no outgoing calls
no test coverage detected