helper functions¶
-
hopfield4py.hamming(A: tensorflow.python.framework.ops.Tensor, B: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.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: tensorflow.python.framework.ops.Tensor, data_tensor: tensorflow.python.framework.ops.Tensor, model: hopfield4py.hopfield.Hopfield) → tensorflow.python.framework.ops.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: tensorflow.python.framework.ops.Tensor, data_tensor: tensorflow.python.framework.ops.Tensor, model: hopfield4py.hopfield.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: tensorflow.python.framework.ops.Tensor, data_tensor: tensorflow.python.framework.ops.Tensor, model: hopfield4py.hopfield.Hopfield) → tensorflow.python.framework.ops.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