pytorch / text

Models, data loaders and abstractions for language processing, powered by PyTorch
https://pytorch.org/text
BSD 3-Clause "New" or "Revised" License
3.51k stars 810 forks source link

NestedField modifies the attribute include_lengths of the NestingField #357

Open kent930 opened 6 years ago

kent930 commented 6 years ago

Hi, The methods pad() and numericalize() of NestedField set the attribute include_lengths of the NestingField to True after the first call to the NestedField.

This introduces an inconsistent behaviour since I'm also using the NestingField with the attribute include_lengths=False as another field and it returns a tensor for the first call and then a tuple.

Is there a reason for that, or should this parameter be replaced by its original value after the padding (like fix length for example, self.nesting_field.fix_length = old_fix_len).

Thanks

zhangguanheng66 commented 5 years ago

@kent930 if you can provide a script to reproduce the issue, I'm happy to take a look at it.