Example #1
0
    def _make_optimizers(self):
        optimizers = super()._make_optimizers()
        config = dutil.deep_merge(
            DEFAULT_OPTIM_CONFIG,
            self.config["optimizer"],
            new_keys_allowed=False,
            allow_new_subkey_list=[],
            override_all_if_type_changes=["actor", "critic"],
        )
        assert config["actor"]["type"] in [
            "KFAC",
            "EKFAC",
        ], "ACKTR must use optimizer with Kronecker Factored curvature estimation."

        mapping = {
            "actor": build_optimizer(self.module.actor, config["actor"]),
            "critic": build_optimizer(self.module.critic, config["critic"]),
        }

        optimizers.update(mapping)
        return optimizers
Example #2
0
    def _make_optimizers(self):
        optimizers = super()._make_optimizers()
        config = self.config["optimizer"]

        components = "actor critics alpha".split()
        mapping = {
            name: build_optimizer(getattr(self.module, name), config[name])
            for name in components
        }

        optimizers.update(mapping)
        return optimizers
Example #3
0
    def _make_optimizers(self):
        optimizers = super()._make_optimizers()
        config = self.config["optimizer"]
        component_map = {
            "on_policy": self.module.actor,
            "off_policy":
            nn.ModuleList([self.module.model, self.module.critic]),
        }

        mapping = {
            name: build_optimizer(module, config[name])
            for name, module in component_map.items()
        }

        optimizers.update(mapping)
        return optimizers
Example #4
0
    def _make_optimizers(self):
        optimizers = super()._make_optimizers()
        config = self.config["optimizer"]
        module = self.module
        components = {
            "model": module.model,
            "actor": module.actor,
            "critic": module.critic,
            "alpha": module.alpha,
        }

        mapping = {
            name: build_optimizer(module, config[name])
            for name, module in components.items()
        }

        optimizers.update(mapping)
        return optimizers
Example #5
0
 def _make_optimizers(self):
     optimizers = super()._make_optimizers()
     optimizers.update(
         naf=build_optimizer(self.module.critics, self.config["optimizer"]))
     return optimizers
Example #6
0
 def _make_optimizers(self):
     optimizers = super()._make_optimizers()
     config = self.config["optimizer"]
     optimizers["actor"] = build_optimizer(self.module.actor, config["actor"])
     optimizers["critics"] = build_optimizer(self.module.critics, config["critics"])
     return optimizers
Example #7
0
def optimizer(models):
    return build_optimizer(models, {"type": "Adam"})
Example #8
0
 def _make_optimizers(self):
     optimizers = super()._make_optimizers()
     config = self.config["optimizer"]
     optimizers["models"] = build_optimizer(self.module.models, config["models"])
     return optimizers