Migrating a PyTorch 1.2.0 Model to 2.1.0 - AttributeError in GRU Module

Hello PyTorch Community,

I’m attempting to migrate a model from PyTorch 1.2.0 to 2.1.0 as part of replicating the results from a paper called SEGBOT. I’ve found a repository that has reproduced the paper: SEGBOT Repository

However, when I try to run the code with PyTorch 2.1.0, I encounter the following error:

AttributeError: 'GRU' object has no attribute '_flat_weights'. Did you mean: '_all_weights'?

This error appears during the loading of a pre-trained model using torch.load. Here’s the snippet of the code where the error occurs:

mymodel = torch.load('trained_model.torchsave', map_location=lambda storage, loc: storage)

From my understanding, this seems to relate to a change in the GRU module between versions. As I’m new to the field, I would greatly appreciate any guidance on how to address this issue to make the model compatible with the latest PyTorch version.

Thank you for your assistance.