All problems
Logistic Hessian-Vector Product
Problem
For the logistic loss L(w) = log(1 + exp(-y * w dot x)) with label y in {+1, -1}, let p = 1 / (1 + exp(y * w dot x)) and c = p * (1 - p).
The Hessian is c * x x^T, so the Hessian-vector product with a vector v is c * (x dot v) * x. Given w, x, y, and v, return that product.
Hint
The Hessian is a rank-one outer product scaled by the sigmoid variance.
Test cases
case 1
in: [[0,0],[1,1],1,[1,0]]
expected: [0.25,0.25]
case 2
in: [[1,0],[2,0],1,[1,1]]
expected: [0.419974341614026,0]
case 3
in: [[0,1],[1,-2],-1,[2,1]]
expected: [0,0]
case 4
in: [[0.5,-0.5],[1,1],1,[1,-1]]
expected: [0,0]
Starter codePython
def logistic_hessian_vector_product(w, x, y, v):
# Return H @ v
# Your code here
pass4 test cases · run your code against them in the editor