Skip to content

Conversation

@kahne
Copy link
Contributor

@kahne kahne commented May 2, 2018

There is a merged PR #5300 trying to make ReduceLROnPlateau serializable and resolve issue #5218. However, it's still not working. Moreover, it's more consistent to provide the common state_dict/load_state_dict interface for serialization.

@ezyang
Copy link
Contributor

ezyang commented May 2, 2018

Thanks @kahne. Is there a test we can add for this?

@kahne
Copy link
Contributor Author

kahne commented May 2, 2018

@ezyang I tested it manually with torch.save() and torch.load(). Is there any existing tests for lr scheduler that I can refer to? Thanks!

self.is_better = partial(self._cmp, mode, threshold_mode, threshold)

def state_dict(self):
return {key: value for key, value in self.__dict__.items() if key not in {'optimizer', 'is_better'}}

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@apaszke
Copy link
Contributor

apaszke commented May 2, 2018

@kahne there are a few tests in test/test_optim.py

@kahne
Copy link
Contributor Author

kahne commented May 8, 2018

@pytorchbot retest this please

@kahne
Copy link
Contributor Author

kahne commented May 9, 2018

@ezyang @apaszke tests added

@apaszke apaszke merged commit a257bd1 into pytorch:master May 10, 2018
@apaszke
Copy link
Contributor

apaszke commented May 10, 2018

Thanks @kahne!

onnxbot added a commit to onnxbot/onnx-fb-universe that referenced this pull request May 10, 2018
weiyangfb pushed a commit to weiyangfb/pytorch that referenced this pull request Jun 11, 2018
@ignaciorlando
Copy link

Hi!

I'm trying to use state_dict() on ReduceLROnPlateau but I got this error:
AttributeError: 'ReduceLROnPlateau' object has no attribute 'state_dict'

I'm using pytorch 0.4.0.

Thanks!

@kahne
Copy link
Contributor Author

kahne commented Aug 31, 2018

@ignaciorlando Hi! This feature is available in 0.4.1 but not 0.4.0. Can you upgrade to 0.4.1 and try again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants