raskr / rust-autograd

Tensors and differentiable operations (like TensorFlow) in Rust
MIT License
487 stars 37 forks source link

Adam optimizer is broken? #16

Closed zekyll closed 5 years ago

zekyll commented 5 years ago

I was trying to use the Adam optimizer for a DQN problem, but the the Q values always kept diverging regardless of hyperparameters. So I looked into the code and it seems to me like the optimizer doesn't correctly update the stateful parameters. It calculates new values for m and v but while doing so it makes copies of the NdArrays. The actual state variables referenced by xs[2] and xs[3] are never updated so on each iteration the optimizer just uses zero initialized values for m and v.

raskr commented 5 years ago

Oh yes, new_m and new_v must be set to xs[2] and xs[3]... (I forgot when that code was checked in) I'll fix it later.

raskr commented 5 years ago

Fixed in v0.9.2.