Thanks for your reply! It was really helpful. I have a prototype of the function up and running, but I’m running into some difficulty.
Let’s say I’m trying to differentiate my cost function with respect to variables y, x, theta, and S (as above) - so I have a FloatTensor of length 4.
My cost function involves the variables themselves in non-uniform ways (i.e. I can’t just do matrix multiplication, I have to index each variable from the Tensor specifically), and I’m getting an error I don’t know how to fix.
Minimal example of what I’m trying to do:
x = [x0, x1]
y = 2x0 + 4x1^2
then get dy / dx0 and dy / dx1 (where dy / dx0 = 2 and dy / dx1 = 8x1)
In code:
x = autograd.Variable(torch.FloatTensor([1, 2]), requires_grad=True)
y = 2 * x[0] + 3 * x[1]^ 2
y.backward()
y.grad
The last part gives me this error:
RuntimeError: bitxor is only supported for integer type tensors at d:\pytorch\pytorch\torch\lib\th\generic/THTensorMath.c:961
Does what I’m saying make sense?