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

RuntimeError: 
'module' object is not iterable:

from

        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.

Thanks.

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: https://pytorch.org/docs/master/jit_language_reference.html#iterables

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