未验证 提交 afb56e8c 编写于 作者: S Sing_chan 提交者: GitHub

cut off relation between xk and initial_position's graph (#41371)

* cut off relation between xk and initial_position's graph

* fix_bug

* add detach to cut off with original graph
上级 eb6d7da9
......@@ -126,7 +126,8 @@ def minimize_bfgs(objective_func,
check_initial_inverse_hessian_estimate(initial_inverse_hessian_estimate)
Hk = paddle.assign(initial_inverse_hessian_estimate)
xk = initial_position
# use detach and assign to create new tensor rather than =, or xk will share memory and grad with initial_position
xk = paddle.assign(initial_position.detach())
value, g1 = _value_and_gradient(objective_func, xk)
num_func_calls = paddle.full(shape=[1], fill_value=1, dtype='int64')
......
......@@ -113,7 +113,8 @@ def minimize_lbfgs(objective_func,
check_initial_inverse_hessian_estimate(initial_inverse_hessian_estimate)
H0 = initial_inverse_hessian_estimate
xk = initial_position
# use detach and assign to create new tensor rather than =, or xk will share memory and grad with initial_position
xk = paddle.assign(initial_position.detach())
value, g1 = _value_and_gradient(objective_func, xk)
k = paddle.full(shape=[1], fill_value=0, dtype='int64')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册