This commit is contained in:
+6
-4
@@ -40,10 +40,12 @@ MAX_HOPFIELD_ITER = 200
|
||||
|
||||
def recall_hopfield(weights, input_vec)
|
||||
current = input_vec.dup
|
||||
MAX_HOPFIELD_ITER.times do
|
||||
next_vec = step_hopfield(weights, current)
|
||||
return current if vectors_equal?(current, next_vec)
|
||||
next_vec = step_hopfield(weights, current)
|
||||
iter = 1
|
||||
while !vectors_equal?(current, next_vec) && iter < MAX_HOPFIELD_ITER
|
||||
current = next_vec
|
||||
next_vec = step_hopfield(weights, current)
|
||||
iter += 1
|
||||
end
|
||||
current
|
||||
next_vec
|
||||
end
|
||||
Reference in New Issue
Block a user