Add initial implementation of Hopfield and Hamming networks with web interface
- Create Dockerfile and entrypoint script for application setup - Implement pattern loading from Excel and weight caching - Develop core functions for Hopfield and Hamming networks - Add Sinatra web server for user interaction - Create HTML interface for displaying patterns and results - Include necessary gems in Gemfile and lockfile - Add .dockerignore and .gitignore files
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
def to_vector(matrix)
|
||||
matrix.flatten
|
||||
end
|
||||
|
||||
def to_matrix(vector)
|
||||
vector.each_slice(8).to_a
|
||||
end
|
||||
|
||||
# критерий остановки
|
||||
def vectors_equal?(v1, v2, eps = EPS)
|
||||
v1.zip(v2).all? { |a, b| (a - b).abs < eps }
|
||||
end
|
||||
|
||||
# вывод паттерна в терминал
|
||||
def print_pattern(vector)
|
||||
to_matrix(vector).each do |row|
|
||||
puts row.map { |v| v == 1 ? '█' : ' ' }.join
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user