MCPcopy Create free account
hub / github.com/BindsNET/bindsnet / get_square_assignments

Function get_square_assignments

bindsnet/utils.py:88–109  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

86
87
88def 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
112def reshape_locally_connected_weights(

Callers 4

SOM_LM-SNNs.pyFile · 0.90
batch_eth_mnist.pyFile · 0.90
eth_mnist.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected