your ‘hidden’ variable used in self.gru(x, hidden) is not created appropriately, I’d guess that 32 is hardcoded somewhere; if you use zeros as initial state, simplest fix is to actually omit second parameter