Your question is Implementing a Basic Neural Network. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
For an Agentic AI Engineer evaluation at KMS Technology, implement a small binary classifier without using machine-learning libraries. The model must contain an input layer, one fully connected hidden layer, and one sigmoid output neuron, then train it with batch gradient descent.
Implement train_neural_network(X, y, hidden_size, epochs, learning_rate), where X is a list of n feature vectors and y is a list of binary labels. Initialize all weights deterministically from their indices so repeated calls produce identical results. Use sigmoid activation in the hidden and output layers, binary cross-entropy training, and backpropagation. Return a list of predicted labels after training, using 0 for output probabilities below 0.5 and 1 otherwise.
Do not use NumPy, PyTorch, TensorFlow, or other machine-learning libraries. You may use Python's math module.
Example 1
Input: X = [[0, 0], [0, 1], [1, 0], [1, 1]], y = [0, 1, 1, 0], hidden_size = 4, epochs = 10000, learning_rate = 1.0
Output: [0, 1, 1, 0]
The hidden layer learns intermediate nonlinear features, allowing the network to represent XOR.
Example 2
Input: X = [[0], [1], [2], [3]], y = [0, 0, 1, 1], hidden_size = 3, epochs = 5000, learning_rate = 0.5
Output: [0, 0, 1, 1]
The learned output separates the lower-valued inputs from the higher-valued inputs.
1 <= n <= 2001 <= len(X[i]) <= 202 <= hidden_size <= 200 <= y[i] <= 11 <= epochs <= 200000 < learning_rate <= 2[-2, 2]len(X) == len(y) and every feature vector has the same lengthdef train_neural_network(X, y, hidden_size, epochs, learning_rate):