Implement trace functionality for Hopfield and Hamming networks; update Gemfile.lock and app.rb for new dependencies and features
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
def trace_hopfield_step(weights, vector)
|
||||
n = vector.length
|
||||
Array.new(n) { |i| n.times.sum { |j| weights[i][j] * vector[j] } }
|
||||
end
|
||||
|
||||
def hamming_trace(pattern_vectors, input_vec)
|
||||
n = input_vec.length
|
||||
k = pattern_vectors.length
|
||||
dots = pattern_vectors.map { |pv| pv.zip(input_vec).sum { |a, b| a * b } }
|
||||
initial = dots.map { |dot| (dot.to_f + n) / 2.0 }
|
||||
{
|
||||
eps: (0.9 / k).round(6),
|
||||
k: k,
|
||||
n: n,
|
||||
dot_products: dots,
|
||||
initial_outputs: initial.map { |v| v.round(2) }
|
||||
}
|
||||
end
|
||||
Reference in New Issue
Block a user