{"id":16540144,"url":"https://github.com/rickstaa/lac-tf2-torch-translation","last_synced_at":"2026-05-13T02:10:38.729Z","repository":{"id":55601197,"uuid":"291784049","full_name":"rickstaa/LAC-TF2-TORCH-translation","owner":"rickstaa","description":"Temporary repository to debug what goes wrong during the translation of the LAC algorithm from TF1 to Torch.","archived":false,"fork":false,"pushed_at":"2021-08-19T13:41:23.000Z","size":19830,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-14T07:31:33.296Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rickstaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-31T17:44:18.000Z","updated_at":"2023-07-07T10:32:33.000Z","dependencies_parsed_at":"2022-08-15T04:10:16.667Z","dependency_job_id":null,"html_url":"https://github.com/rickstaa/LAC-TF2-TORCH-translation","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickstaa%2FLAC-TF2-TORCH-translation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickstaa%2FLAC-TF2-TORCH-translation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickstaa%2FLAC-TF2-TORCH-translation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickstaa%2FLAC-TF2-TORCH-translation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rickstaa","download_url":"https://codeload.github.com/rickstaa/LAC-TF2-TORCH-translation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241774228,"owners_count":20018232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-11T18:51:40.568Z","updated_at":"2026-05-13T02:10:33.696Z","avatar_url":"https://github.com/rickstaa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"| :warning: | This repository is no longer maintained. Please use [bayesian-learning-control](https://github.com/rickstaa/bayesian-learning-control) instead! |\n| --------- | --------------------------------------------------------------------------------------------------------------------------------------------- |\n\n# LAC TF2 TORCH translation\n\nI used this repository to translate the LAC code of [Minghoa](https://github.com/hithmh/Actor-critic-with-stability-guarantee) into tf2 and Pytorch code. It currently contains the following translations:\n\n-   [LAC_ORIGINAL](https://github.com/rickstaa/LAC_TF2_TORCH_TRANSLATION/tree/master/LAC_ORIGINAL): The original LAC code of [Minghoa](https://github.com/hithmh/Actor-critic-with-stability-guarantee) as received from @panweihit.\n-   [LAC_TF2](https://github.com/rickstaa/LAC_TF2_TORCH_TRANSLATION/tree/master/LAC_TF2): The LAC code translated to TF2.\n-   [LAC_TF2_GRAPH](https://github.com/rickstaa/LAC_TF2_TORCH_TRANSLATION/tree/master/LAC_TF2_GRAPH): The LAC code translated to TF2 but now with EAGER mode disabled (Deprecated due to performance issues). This version also works with TF1.15.\n-   [LAC_TORCH](https://github.com/rickstaa/LAC_TF2_TORCH_TRANSLATION/tree/master/LAC_TORCH): The LAC code translated into Pytorch code.\n\nAll these solutions will give the same results but will differ in training time. The [LAC_TF2](https://github.com/rickstaa/LAC_TF2_TORCH_TRANSLATION/tree/master/LAC_TF2) version is currently the fastest solution.\n\n## Usage instructions\n\nBelow you will find the general instructions on how to use this package. Additionally, every translation also contains its own README.md.\n\n### Setup the python environment\n\n### Conda environment\n\nFrom the general python package sanity perspective, it is a good idea to use Conda environments to make sure packages from different projects do not interfere with each other.\n\nTo create a Conda env with python3, one runs:\n\n```bash\nconda create -n \u003cENV_NAME\u003e python=\u003cPYTHON_VERSION\u003e\n```\n\nTo activate the env:\n\n```bash\nconda activate \u003cENV_NAME\u003e\n```\n\n### Install dependencies\n\nAfter you created and activated the Conda environment, you have to install the python dependencies. This can be done using the\nfollowing command:\n\n```bash\npip install -r requirements.txt\n```\n\n## Train instructions\n\n### Change training parameters\n\nYou can change the training parameters in the [variant.py](https://github.com/rickstaa/LAC_TF2_TORCH_TRANSLATION/blob/master/LAC_TF2/variant.py) file. The essential variables are explained below:\n\n-   **ENV_NAME**: The environment in which you want to train your agent.\n-   **EPISODES**: The number of episodes you want the agent to perform.\n-   **NUM_OF_POLICIES**: The number of (distinct) agents you want to train.\n-   **USE_LYAPUNOV**: Whether you want to use the LAC (`use_lyapunov=True`) or SAC (`use_lyapunov=False`) algorithm.\n-   **ENV_SEED**: The random seed used for the environment. Set to None if you don't want the environment to be deterministic.\n-   **RANDOM_SEED**: The random seed of the rest of the script. Set to None if you do not want the script to be deterministic.\n-   **CONTINUE_TRAINING**: Whether we want to continue training an already trained model.\n-   **CONTINUE_MODEL_FOLDER**: The path of the model for which you want to continue the training\n-   **SAVE_CHECKPOINTS**: Store intermediate models.\n-   **CHECKPOINT_SAVE_FREQ**: Intermediate model save frequency.\n\n### Start the training\n\nAfter you set the right hyperparameter in the [variant.py](https://github.com/rickstaa/LAC_TF2_TORCH_TRANSLATION/blob/master/LAC_TF2/variant.py) file, you can train an\nalgorithm in a specific folder using the following command:\n\n```bash\npython \u003cLAC_VERSION_NAME\u003e/train.py\n```\n\n## Inference instructions\n\n### Change training parameters\n\nYou can change the inference parameters in the [variant.py](https://github.com/rickstaa/LAC_TF2_TORCH_TRANSLATION/blob/master/LAC_TF2/variant.py) file. The essential variables are explained below:\n\n-   **EVAL_LIST**: The names of the agents you want to run the inference for.\n-   **WHICH_POLICY_FOR_INFERENCE**: Which policies of a trained agent you want to use for the inference. Each trained agent can contain multiple policies (see: `num_of_policies` parameter).\n-   **NUM_OF_PATHS_FOR_EVAL**: How many paths you want to use during the inference.\n\n### Start the inference\n\nAfter you trained an agent, you can evaluate the performance of the algorithm by running\nthe following command:\n\n```bash\npython \u003cLAC_VERSION_NAME\u003e/inference_eval.py --model-name=\u003cMODEL_NAME\u003e --env-name=Ex3_EKF_gyro\n```\n\nAlternatively, you can set the `eval_list` and `ENV_NAME` parameters in the [variant.py](https://github.com/rickstaa/LAC_TF2_TORCH_TRANSLATION/blob/master/LAC_TF2/variant.py) file and\nrun the inference with the shorter command:\n\n```bash\npython \u003cLAC_VERSION_NAME\u003e/inference_eval.py\n```\n\n## Add new environments\n\nNew environments should be added to the `ENVS_PARAMS` variable of the\n[variant.py file](https://github.com/rickstaa/LAC_TF2_TORCH_Translation/blob/f492ceb1ede9c22e5f4fae45085f2393465aeb61/LAC_TF2/variant.py#L111-L144). While doing so please make sure you supply a valid\nmodule and class name:\n\n```python\n\"oscillator\": {\n    \"module_name\": \"envs.oscillator\",\n    \"class_name\": \"oscillator\",\n    \"max_ep_steps\": 800,\n    \"max_global_steps\": TRAIN_PARAMS[\"episodes\"],\n    \"max_episodes\": int(1e6),\n    \"eval_render\": False,\n},\n```\n\nAfter that, the new environment can be used by setting the `ENV_NAME` variable of the\nof the [variant.py file](https://github.com/rickstaa/LAC_TF2_TORCH_Translation/blob/f492ceb1ede9c22e5f4fae45085f2393465aeb61/LAC_TF2/variant.py#L20).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickstaa%2Flac-tf2-torch-translation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frickstaa%2Flac-tf2-torch-translation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickstaa%2Flac-tf2-torch-translation/lists"}