import math def sigmoid(x): return 1 / (1 + math.exp(-x)) def forward(inputs, weights, biases): hidden = [] # Hidden layer for i in range(3): total = 0 for j in range(2): total += inputs[j] * weights[i][j] total += biases[i] hidden.append(sigmoid(total)) # Output layer output = 0 for i in range(3): output += hidden[i] * weights[3][i] output += biases[3] return output # Initial weights weights = [ [0.2, 0.4], [0.3, 0.1], [0.5, 0.2], [0.4, 0.3, 0.2] ] # Initial biases biases = [0.1, 0.2, 0.1, 0.1] # Test inputs = [3, 4] prediction = forward(inputs, weights, biases) print("Prediction:", prediction) print("Expected:", 12)