helper functions¶
- hopfield4py.hamming(A: Tensor, B: Tensor) Tensor ¶
Hamming distance sum(abs((A-B)))/lenght(A)
A and be must have the same shape
- Parameters:
A – first tensor
B – second tensor
- hopfield4py.get_prediction(sample: Tensor, data_tensor: Tensor, model: Hopfield) Tensor ¶
Get the nearest memory
- Parameters:
sample – sample to reconstruct
data_tensor – tensor with memories
model – model used to infer
- Returns:
argmin of the element of data_tensor nearest to sample
- hopfield4py.get_predicted_labels(classes: list, samples: Tensor, data_tensor: Tensor, model: Hopfield) list ¶
Get the classes predicted for each sample
- Parameters:
classes – list of classes names with shape (nclasses,)
samples – samples to reconstruct with shape (nsamples, nspins)
data_tensor – tensor with memories (nclasses, nspins)
- Returns:
tensor with list of classes
- hopfield4py.get_all_prediction(samples: Tensor, data_tensor: Tensor, model: Hopfield) Tensor ¶
Get the nearest memory
- Parameters:
samples – samples to reconstruct
data_tensor – tensor with memories
model – model used to infer
- Returns:
tensor with list of argmin of the element of data_tensor nearest to each sample