Your question is Python Neural Network Implementation. 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.
Capgemini GenAI engineering workflows may require implementing lightweight model components without relying on a machine learning framework. Write a Python function that trains a fully connected neural network with one sigmoid hidden layer and one sigmoid output neuron, then returns predictions for the training samples.
Use batch gradient descent and binary cross-entropy loss. The initial weights and biases are provided, so the function must be deterministic.
Implement train_network(X, y, W1, b1, W2, b2, epochs, learning_rate).
X is a non-empty list of n samples, each containing d floats.y is a list of n binary labels, either 0 or 1.W1 is a d x h matrix connecting inputs to h hidden neurons.b1 is a length-h hidden bias vector.W2 is a length-h vector connecting the hidden layer to the output.b2 is the output bias.epochs is a non-negative integer. learning_rate is positive.epochs batch updates and return a list of n predictions, where each prediction is 1 when the final output probability is at least 0.5, otherwise 0.Use sigmoid activation in both layers. Average gradients across the batch before updating parameters.
def train_network(X, y, W1, b1, W2, b2, epochs, learning_rate):