Hey @tom, some snippets to initialise weights and convert a real valued data_vec to -1 or 1 as they use in the paper above
a) Randomly Initialize weights as -1 or 1
weights = np.random.randint(2, size=10) weights = 2*weights weights = weights-1
b) convert data vectors to -1 or 1
data_vec = torch.randn(out_features, in_features) weights_ge0 = torch.ge(data_vec ,0) # greater than zero weights_le0 = torch.le(data_vec ,0) # less than zero weights_le0xmin1 = torch.mul(weights_le0.float(),-1) # flip 1 to -1 data_vec_for_xnor_layers = weights_ge0.float() + weights_le0xmin1.float()
Cheers,
Aj