As I was playing around with mass_spring.py, I got confused by clear_states(). I was curious why only some of the variable gradients were being cleared. I dug into the TaiChi code and found that with Tape(loss) seems to clear all the variable gradients automatically, so there is no need to clear them in clear_states(). The only thing clear_states() needs to do is reset v_inc.
This shouldn't change how mass_spring.py runs at all (Although I cannot guarantee this because it seems that mass_spring.py is non deterministic and I get a slightly different result each time I run it). This edit should only help reduce confusion for new users.
However, if I have misunderstood clear_states(), let me know. I'm still pretty new to TaiChi.
As I was playing around with mass_spring.py, I got confused by clear_states(). I was curious why only some of the variable gradients were being cleared. I dug into the TaiChi code and found that
with Tape(loss)
seems to clear all the variable gradients automatically, so there is no need to clear them in clear_states(). The only thing clear_states() needs to do is reset v_inc.This shouldn't change how mass_spring.py runs at all (Although I cannot guarantee this because it seems that mass_spring.py is non deterministic and I get a slightly different result each time I run it). This edit should only help reduce confusion for new users.
However, if I have misunderstood clear_states(), let me know. I'm still pretty new to TaiChi.