Skip to content

adding get and set lr for optimizer - #13661

Merged
Adam Louly (AdamLouly) merged 3 commits into
mainfrom
adamlouly/expose_get_set_lr
Dec 7, 2022
Merged

Adam Louly (AdamLouly) merged 3 commits into
mainfrom
adamlouly/expose_get_set_lr

Conversation

@AdamLouly

Copy link
Copy Markdown
Contributor

Description

Exposing get and set Learning rate for optimizer

Motivation and Context

you can now set learning rate for optimizer.

@baijumeswani Baiju Meswani (baijumeswani) added the training issues related to ONNX Runtime training; typically submitted using template label Nov 21, 2022
"""
self._optimizer.optimizer_step()

def set_learning_rate(self, learning_rate):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add type hints if possible.

optimizer = Optimizer(optimizer_file_path, model)

# Test get and set learning rate.
lr = optimizer.get_learning_rate()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you test the default learning rate?

optimizer.set_learning_rate(0.5)
new_lr = optimizer.get_learning_rate()

assert lr != new_lr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add assert isclose(new_lr, 0.5)?

@AdamLouly

Copy link
Copy Markdown
Contributor Author

Thanks for the review

@AdamLouly
Adam Louly (AdamLouly) merged commit f453d28 into main Dec 7, 2022
@AdamLouly
Adam Louly (AdamLouly) deleted the adamlouly/expose_get_set_lr branch December 7, 2022 19:59
Baiju Meswani (baijumeswani) pushed a commit that referenced this pull request Dec 13, 2022
### Description
Exposing get and set Learning rate for optimizer


### Motivation and Context
you can now set learning rate for optimizer.
MS (simon-moo) pushed a commit to simon-moo/onnxruntime that referenced this pull request Dec 26, 2022
### Description
Exposing get and set Learning rate for optimizer


### Motivation and Context
you can now set learning rate for optimizer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

training issues related to ONNX Runtime training; typically submitted using template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants