import math def sigmoid(x): return 1 / (1 + math.exp(-x)) def neuron(inputs, weights, bias): total = 0 for x, w in zip(inputs, weights): total += x * w total += bias return sigmoid(total) def loss_function(expected, predicted): return (expected - predicted) ** 2 # Inputs inputs = [3, 7] # Hidden layer h1 = neuron(inputs, [0.2, 0.4], 0.1) h2 = neuron(inputs, [0.3, 0.1], 0.2) # Output layer output = neuron([h1, h2], [0.5, 0.6], 0.1) # Expected answer expected = 21 # Calculate loss loss = loss_function(expected, output) print("Prediction:", output) print("Expected:", expected) print("Loss:", loss)