Skip to content

Commit 4eaf9e4

Browse files
authored
add self.metric for ReduceLROnPlateau optimizer
1 parent bd73e45 commit 4eaf9e4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

models/base_model.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def __init__(self, opt):
4141
self.visual_names = []
4242
self.optimizers = []
4343
self.image_paths = []
44+
self.metric = 0 # used for learning rate policy 'plateau'
4445

4546
@staticmethod
4647
def modify_commandline_options(parser, is_train):
@@ -115,7 +116,7 @@ def get_image_paths(self):
115116
def update_learning_rate(self):
116117
"""Update learning rates for all the networks; called at the end of every epoch"""
117118
for scheduler in self.schedulers:
118-
scheduler.step()
119+
scheduler.step(self.metric)
119120
lr = self.optimizers[0].param_groups[0]['lr']
120121
print('learning rate = %.7f' % lr)
121122

0 commit comments

Comments
 (0)