Can't enumerate through a ModuleList

I’m using Pytorch 1.2.0 with Python 3.7, and I can’t enumerate through a ModuleList.
I’m using this code

for i,direction in enumerate(self.directions):
            state = states[i]
            out, out_state = direction(inp, state)
            outputs += [out]
            output_states += [out_state]

, which is based from here. and I’m getting

'module' object is not iterable:


        for i,direction in enumerate(self.directions):
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...  <--- HERE

I’ve clicked the link about enumerating in the original file(the link above), it said that enumerating is already supporterd. Since I can’t use it, can someone please tell me what should I do.


Hi, @G.M, this is fixed in our most recent release (1.4). Could you try updating your pytorch version and giving it another go?

1 Like

Thank u very much. That’s the problem. :slight_smile:

But enumerate doesn’t seem to be in the 1.4.0 doc. And do u know where can I find a release note or something similar to that for Pytorch?

Good point, I think that was an omission. I’ll add a section to iterators to the docs shortly and link it here.

1 Like

Hi, turns out we already had a (small) section here:

Alright thx :slight_smile:, I thought it was in the 1.4.0 doc.