def analytical_gradients(network, X, Y):
    print("Calculating analytical gradients...")
    print("Forward pass:", end=" ")
    preds = network.predict(X)
    print("done! Backward pass:", end=" ")
    delta = network.cost.derivative(preds, Y)
    network.backpropagate(delta)
    print("done!")
    return network.get_gradients(unfold=True)