Update app.py
Browse files
app.py
CHANGED
@@ -39,27 +39,27 @@ def update_graph(input_size, hidden_size, output_size, input_color, hidden_color
|
|
39 |
# Connections from input layer to hidden layer
|
40 |
for i in range(input_size):
|
41 |
for j in range(hidden_size):
|
42 |
-
G.add_edge(f'I{i}', f'H{j}', weight=np.random.rand())
|
43 |
|
44 |
# Connections from hidden layer to output layer
|
45 |
for j in range(hidden_size):
|
46 |
for k in range(output_size):
|
47 |
-
G.add_edge(f'H{j}', f'O{k}', weight=np.random.rand())
|
48 |
|
49 |
# Calculate neuron positions
|
50 |
pos = {}
|
51 |
|
52 |
# Input layer positions
|
53 |
for i in range(input_size):
|
54 |
-
pos[f'I{i}'] = (0, 1 - (i / (input_size - 1))) # Vertically aligned
|
55 |
|
56 |
# Hidden layer positions
|
57 |
for i in range(hidden_size):
|
58 |
-
pos[f'H{i}'] = (1, 1 - (i / (hidden_size - 1))) # Vertically aligned
|
59 |
|
60 |
# Output layer positions
|
61 |
for i in range(output_size):
|
62 |
-
pos[f'O{i}'] = (2, 1 - (i / (output_size - 1))) # Vertically aligned
|
63 |
|
64 |
# Visualize edge weights
|
65 |
edges = G.edges(data=True)
|
|
|
39 |
# Connections from input layer to hidden layer
|
40 |
for i in range(input_size):
|
41 |
for j in range(hidden_size):
|
42 |
+
G.add_edge(f'I{i+1}', f'H{j+1}', weight=np.random.rand())
|
43 |
|
44 |
# Connections from hidden layer to output layer
|
45 |
for j in range(hidden_size):
|
46 |
for k in range(output_size):
|
47 |
+
G.add_edge(f'H{j+1}', f'O{k+1}', weight=np.random.rand())
|
48 |
|
49 |
# Calculate neuron positions
|
50 |
pos = {}
|
51 |
|
52 |
# Input layer positions
|
53 |
for i in range(input_size):
|
54 |
+
pos[f'I{i+1}'] = (0, 1 - (i / (input_size - 1))) # Vertically aligned
|
55 |
|
56 |
# Hidden layer positions
|
57 |
for i in range(hidden_size):
|
58 |
+
pos[f'H{i+1}'] = (1, 1 - (i / (hidden_size - 1))) # Vertically aligned
|
59 |
|
60 |
# Output layer positions
|
61 |
for i in range(output_size):
|
62 |
+
pos[f'O{i+1}'] = (2, 1 - (i / (output_size - 1))) # Vertically aligned
|
63 |
|
64 |
# Visualize edge weights
|
65 |
edges = G.edges(data=True)
|