Replies: 2 comments 1 reply
-
I think the origin of the problem may be the mix use of tf.Tensor and np.array, you can try to refactor the code as the follows and see whether it works (always pay attention to the type (tensor/array) and dtype(real/complex) of each variable). @tc.backend.jit
def f(theta, h_t):
lhs = lhs_matrix(theta,psi0)
rhs = rhs_vector(theta,psi0, h_t)
eps = 1e-4
lhs += eps * tc.backend.eye(l * ltheta, dtype=lhs.dtype)
return tc.backend.solve(lhs, rhs, assume_a="sym")
def f_vqs(t, theta):
h_t =
theta = tc.backend.convert_to_tensor(theta)
r = f(theta, h_t)
return tc.backend.numpy(r)
result_solve_ode= solve_ivp(f_vqs,t_span,theta0,method='RK45') |
Beta Was this translation helpful? Give feedback.
1 reply
-
And for anyone who is interested, I have added a numpy interface, so the code for def f(theta, h_t):
pass
f_np = tc.interfaces.numpy_interface(f)
def f_vqs(t, theta):
h_t =
return f_np(theta, h_t) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Naively, I replaced the propagator
update
function invariational_dynamics.ipynb
directly withsolv_ivp
inscipy
, but I came to the problems:TypeError: Expected complex128, but got Tensor("h_t0:0", shape=(), dtype=int32) of type 'Tensor'.
Could you suggest how to resolve it. Thanks.Beta Was this translation helpful? Give feedback.
All reactions