joschu / cgt

Computation Graph Toolkit
Other
628 stars 87 forks source link

Simple operation breaks CGT #64

Open EdsterG opened 8 years ago

EdsterG commented 8 years ago

The following code doesn't work:

x = np.array([31,-2])
K = np.array([[3,5],[7,11],[13,17]])

_x = cgt.vector(fixed_shape=[2], name="x")
_K = cgt.matrix(fixed_shape=[3,2], name="K")

grad_K = cgt.grad(_K.dot(_x)[0], _K)
grad_K_x = cgt.grad(grad_K[0,0], _x)
f_K_x = cgt.function([_x, _K], grad_K_x)
print f_K_x(x,K) # should be [1,0]