https://github.com/rickstaa/tf2-eager-vs-graph-grad-problem
Small repository that shows the problems I encountered while translating tf1 code to tf2 eager code.
https://github.com/rickstaa/tf2-eager-vs-graph-grad-problem
Last synced: 1 day ago
JSON representation
Small repository that shows the problems I encountered while translating tf1 code to tf2 eager code.
- Host: GitHub
- URL: https://github.com/rickstaa/tf2-eager-vs-graph-grad-problem
- Owner: rickstaa
- Created: 2020-09-18T16:44:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-22T07:22:53.000Z (over 5 years ago)
- Last Synced: 2025-03-04T03:20:10.603Z (over 1 year ago)
- Language: Python
- Size: 271 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tf2 Eager vs Graph gradients problem
A Simple example repository to show the problems I have with computing gradients of a
Squashed gaussian actor [Haarnoja et al. 2019](https://arxiv.org/abs/1801.01290). I
encountered these problems when I tried to translate the tf1 code of the Lyapunov Actor
Critic Agent of [Han et al 2019](http://arxiv.org/abs/2004.14288) into tf2 eager code.
## Use instructions
### Conda environment
From 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.
To create a conda env with python3, one runs
```bash
conda create -n lac_clean_tf2_eager python=3.8
```
To activate the env:
```bash
conda activate lac_clean_tf2_eager
```
### Installation Environment
```bash
pip install -r requirements.txt
```
Then you are free to run main.py to train agents. Hyperparameters for training LAC in Cartpole are ready to run by default. If you would like to test other environments and algorithms, please open variant.py and choose corresponding 'env_name' and 'algorithm_name'.
### Run scripts
#### Full LAC implementations
The full LAC implementations LAC-tf1, LAC-tf2-eager and LAC-tf2-GRAPH can be started with the following python command:
```bash
python LAC-tf1/train.py
```
#### Grad problem scripts
The grad problem scripts can be started with the following python command:
```python
python tf2_val_grad_eager.py
```