mirror of
https://github.com/facebookresearch/ReAgent.git
synced 2026-05-17 12:40:39 +00:00
20f3d33382
Summary: Make all the optimizers and schedulers in torch.optim available for use. (except CyclicLR, which has a Callable field `scale_fn` that's unsupported by FBL) Convert DiscreteDQN and QRDQN to trainers to use this new format. After this diff, OptimizerParameters would be deprecated. Instead, you should specify optimizer directly via the registry. Pull Request resolved: https://github.com/facebookresearch/ReAgent/pull/259 Reviewed By: badrinarayan Differential Revision: D21470948 fbshipit-source-id: 793222adbfebb87b064dbe7768bbbea89b2129dd
20 lines
399 B
Python
20 lines
399 B
Python
#!/usr/bin/env python3
|
|
|
|
import inspect
|
|
|
|
import torch
|
|
|
|
|
|
def is_strict_subclass(a, b):
|
|
if not inspect.isclass(a) or not inspect.isclass(b):
|
|
return False
|
|
return issubclass(a, b) and a != b
|
|
|
|
|
|
def is_torch_optimizer(cls):
|
|
return is_strict_subclass(cls, torch.optim.Optimizer)
|
|
|
|
|
|
def is_torch_lr_scheduler(cls):
|
|
return is_strict_subclass(cls, torch.optim.lr_scheduler._LRScheduler)
|