{"id":17243556,"url":"https://github.com/gabotechs/lazaro","last_synced_at":"2026-01-23T05:36:47.399Z","repository":{"id":62575267,"uuid":"327275023","full_name":"gabotechs/lazaro","owner":"gabotechs","description":"Reinforcement learning framework for implementing custom models on custom environments using state of the art RL algorithms","archived":false,"fork":false,"pushed_at":"2021-05-14T14:10:43.000Z","size":1705,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T11:13:54.422Z","etag":null,"topics":["actor-critic","artificial-intelligence","deep-learning","deep-learning-algorithms","deep-q-learning","deep-q-learning-network","deep-q-network","deep-reinforcement-learning","ppo","reinforcement-learning","reinforcement-learning-agent","reinforcement-learning-algorithms"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gabotechs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-06T10:21:22.000Z","updated_at":"2022-11-06T19:27:56.000Z","dependencies_parsed_at":"2022-11-03T20:44:43.167Z","dependency_job_id":null,"html_url":"https://github.com/gabotechs/lazaro","commit_stats":null,"previous_names":["gabrielmusat/lazaro"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gabotechs/lazaro","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabotechs%2Flazaro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabotechs%2Flazaro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabotechs%2Flazaro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabotechs%2Flazaro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gabotechs","download_url":"https://codeload.github.com/gabotechs/lazaro/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabotechs%2Flazaro/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28681006,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T04:33:33.518Z","status":"ssl_error","status_checked_at":"2026-01-23T04:33:30.433Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actor-critic","artificial-intelligence","deep-learning","deep-learning-algorithms","deep-q-learning","deep-q-learning-network","deep-q-network","deep-reinforcement-learning","ppo","reinforcement-learning","reinforcement-learning-agent","reinforcement-learning-algorithms"],"created_at":"2024-10-15T06:16:04.343Z","updated_at":"2026-01-23T05:36:47.381Z","avatar_url":"https://github.com/gabotechs.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\n    \u003cimg height=\"200\" src=\"./docs/assets/lazaro.svg\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/GabrielMusat/lazaro/actions/workflows/test.yml/badge.svg\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg\"/\u003e\n\u003c/p\u003e\n\nReinforcement learning framework based on Pytorch for implementing custom deep learning models\non custom environments using state of the art and modular reinforcement learning algorithms.\n\nDeveloping deep learning models is hard enough to also be worrying about implementing them\ncorrectly in the last reinforcement learning algorithm you saw in a paper. Lazaro takes that weight\nout of the shoulders of the people who work with reinforcement learning, and let developers focus\non their custom deep learning models that solve their custom environments.\n\n# Installation\n\nLazaro package is available on PyPI for Python versions greater or equal to 3.7.\n```shell\npip install lazaro\n```\n\n# Usage\nImport torch and lazaro packages\n```python\nimport torch\nimport torch.nn.functional as F\nimport lazaro as lz\n```\n\nChoose an environment to train your model. You can create one yourself or choose one from the \nenvironments repository. [Here is a cool tutorial](docs/SNAKE_ENV.md) that shows how to build an\nenvironment yourself from scratch.\n```python\nenv = lz.environments.CartPole()\nOBSERVATION_SPACE = 4  # position, speed, angle, rotation speed \nACTION_SPACE = 2  # move right, move left\n```\n\nCreate your custom model using PyTorch.\n\n```python\nclass CustomModel(torch.nn.Module):\n    def __init__(self):\n        super(CustomModel, self).__init__()\n        # your last layer can have an arbitrary number of output neurons, \n        # lazaro will handle the rest of the model for you\n        self.linear = torch.nn.Linear(OBSERVATION_SPACE, 128) \n\n    def forward(self, x):\n        return F.relu(self.linear(x))\n```\nCreate your agent. You can select any agent and mix it with any exploration policy and any replay buffer\nalgorithm.\n```python\n# mix any agent with any exploration policy and any replay buffer\nclass CustomAgent(lz.agents.explorers.NoisyExplorer,\n                  lz.agents.replay_buffers.NStepsPrioritizedReplayBuffer,\n                  lz.agents.DoubleDuelingDqnAgent):  \n    \n    # implement the model factory. It will be used to embed your torch model into the agent\n    def model_factory(self):\n        return CustomModel()\n    \n    # lazaro expects to receive data as torch.Tensor\n    def preprocess(self, x):  # x is the raw state that the environment returns\n        return torch.from_numpy(x.astype(\"float32\"))\n```\nInstantiate your agent and train it in your environment.\n```python\nagent = CustomAgent(action_space=ACTION_SPACE)\nagent.train(env)\n```\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/assets/cartpole.gif\"\u003e\n\u003c/p\u003e\n\n## Custom snake game environment\nIf you want to know how to create your own environment, checkout [this tutorial](docs/SNAKE_ENV.md), where you will build\nthe snake game from scratch in a few lines of code and train an agent on it\n\n## Tensorboard integration\nYou can visualize the learning progress and the agent's neural network graph using Tensorboard.\nIt's very simple:\n```python\nclass CustomAgent(lz.agents.explorers.NoisyExplorer,\n                  lz.agents.replay_buffers.NStepsPrioritizedReplayBuffer,\n                  lz.agents.loggers.TensorBoardLogger,  # \u003c- Just add this, and voila!\n                  lz.agents.DoubleDuelingDqnAgent):  \n    \n    def model_factory(self):\n        return CustomModel()\n    \n    def preprocess(self, x):\n        return torch.from_numpy(x.astype(\"float32\"))\n```\nOnce the training has started, you can go to the Tensorboard local uri (http://localhost:6006) and see useful info\nlike this:\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/assets/tb-charts.png\"\u003e\n    \u003cimg src=\"docs/assets/tb-graph.png\"\u003e\n\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabotechs%2Flazaro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabotechs%2Flazaro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabotechs%2Flazaro/lists"}