This gist is an accumulation of high-quality implementations and packages useful for research in reinforcement learning.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from torch.optim.lr_scheduler import _LRScheduler | |
import numpy as np | |
class InterpolatingScheduler(_LRScheduler): | |
def __init__(self, optimizer, steps, lrs, scale='log', last_epoch=-1): | |
"""A scheduler that interpolates given values | |
Args: | |
- optimizer: pytorch optimizer | |
- steps: list or array with the x coordinates of the interpolated values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
def dict_merge(dct, merge_dct): | |
""" Recursive dict merge. Inspired by :meth:``dict.update()``, instead of | |
updating only top-level keys, dict_merge recurses down into dicts nested | |
to an arbitrary depth, updating keys. The ``merge_dct`` is merged into | |
``dct``. | |
:param dct: dict onto which the merge is executed | |
:param merge_dct: dct merged into dct |