All Projects → VinAIResearch → PCC-pytorch

VinAIResearch / PCC-pytorch

Licence: MIT license
A pytorch implementation of the paper "Prediction, Consistency, Curvature: Representation Learning for Locally-Linear Control"

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to PCC-pytorch

Poincare Embedding
Poincaré Embedding (unofficial)
Stars: ✭ 218 (+282.46%)
Mutual labels:  representation-learning
pgdl
Winning Solution of the NeurIPS 2020 Competition on Predicting Generalization in Deep Learning
Stars: ✭ 36 (-36.84%)
Mutual labels:  representation-learning
VQ-APC
Vector Quantized Autoregressive Predictive Coding (VQ-APC)
Stars: ✭ 34 (-40.35%)
Mutual labels:  representation-learning
Link Prediction
Representation learning for link prediction within social networks
Stars: ✭ 245 (+329.82%)
Mutual labels:  representation-learning
COCO-LM
[NeurIPS 2021] COCO-LM: Correcting and Contrasting Text Sequences for Language Model Pretraining
Stars: ✭ 109 (+91.23%)
Mutual labels:  representation-learning
object-aware-contrastive
Object-aware Contrastive Learning for Debiased Scene Representation (NeurIPS 2021)
Stars: ✭ 44 (-22.81%)
Mutual labels:  representation-learning
Pytorch Byol
PyTorch implementation of Bootstrap Your Own Latent: A New Approach to Self-Supervised Learning
Stars: ✭ 213 (+273.68%)
Mutual labels:  representation-learning
image embeddings
Using efficientnet to provide embeddings for retrieval
Stars: ✭ 107 (+87.72%)
Mutual labels:  representation-learning
DESOM
🌐 Deep Embedded Self-Organizing Map: Joint Representation Learning and Self-Organization
Stars: ✭ 76 (+33.33%)
Mutual labels:  representation-learning
Revisiting-Contrastive-SSL
Revisiting Contrastive Methods for Unsupervised Learning of Visual Representations. [NeurIPS 2021]
Stars: ✭ 81 (+42.11%)
Mutual labels:  representation-learning
Good Papers
I try my best to keep updated cutting-edge knowledge in Machine Learning/Deep Learning and Natural Language Processing. These are my notes on some good papers
Stars: ✭ 248 (+335.09%)
Mutual labels:  representation-learning
pytorch-convcnp
A PyTorch Implementation of Convolutional Conditional Neural Process.
Stars: ✭ 41 (-28.07%)
Mutual labels:  deep-generative-models
Representation-Learning-for-Information-Extraction
Pytorch implementation of Paper by Google Research - Representation Learning for Information Extraction from Form-like Documents.
Stars: ✭ 82 (+43.86%)
Mutual labels:  representation-learning
Contrastive Predictive Coding Pytorch
Contrastive Predictive Coding for Automatic Speaker Verification
Stars: ✭ 223 (+291.23%)
Mutual labels:  representation-learning
deepgtt
DeepGTT: Learning Travel Time Distributions with Deep Generative Model
Stars: ✭ 30 (-47.37%)
Mutual labels:  deep-generative-models
Paddlehelix
Bio-Computing Platform featuring Large-Scale Representation Learning and Multi-Task Deep Learning “螺旋桨”生物计算工具集
Stars: ✭ 213 (+273.68%)
Mutual labels:  representation-learning
Supervised-Contrastive-Learning-in-TensorFlow-2
Implements the ideas presented in https://arxiv.org/pdf/2004.11362v1.pdf by Khosla et al.
Stars: ✭ 117 (+105.26%)
Mutual labels:  representation-learning
anatome
Ἀνατομή is a PyTorch library to analyze representation of neural networks
Stars: ✭ 50 (-12.28%)
Mutual labels:  representation-learning
PC3-pytorch
Predictive Coding for Locally-Linear Control (ICML-2020)
Stars: ✭ 16 (-71.93%)
Mutual labels:  representation-learning
probai-2019
Materials of the Nordic Probabilistic AI School 2019.
Stars: ✭ 127 (+122.81%)
Mutual labels:  deep-generative-models

Prediction, Consistency and Curvature

This is a pytorch implementation of the paper "Prediction, Consistency, Curvature: Representation Learning for Locally-Linear Control". The work was done during the residency at VinAI Research, Hanoi, Vietnam.

Installing

First, clone the repository:

https://github.com/VinAIResearch/PCC-pytorch.git

Then install the dependencies as listed in pcc.yml and activate the environment:

conda env create -f pcc.yml

conda activate pcc

Training

The code currently supports training for planar, pendulum, cartpole and threepole environment. Run the train_pcc.py with your own settings. For example:

python train_pcc.py \
    --env=planar \
    --armotized=False \
    --log_dir=planar_1 \
    --seed=1 \
    --data_size=5000 \
    --noise=0 \
    --batch_size=128 \
    --lam_p=1.0 \
    --lam_c=8.0 \
    --lam_cur=8.0 \
    --vae_coeff=0.01 \
    --determ_coeff=0.3 \
    --lr=0.0005 \
    --decay=0.001 \
    --num_iter=5000 \
    --iter_save=1000 \
    --save_map=True

First, data is sampled according to the given data size and noise level, then PCC model will be trained using the specified settings.

If the argument save_map is set to True, the latent map will be drawn every 10 epoches (for planar only), then the gif file will be saved at the same directory as the trained model.

You can also visualize the training process by running tensorboard --logdir={path_to_log_file}, where path_to_log_file has the form logs/{env}/{log_dir}. The trained model will be saved at result/{env}/{log_dir}.

Visualizing latent maps

You can visualize the latent map for both planar and pendulum, to do that simply run:

python latent_map_planar.py --log_path={log_to_trained_model} --epoch={epoch}
or 
python latent_map_pendulum.py --log_path={log_to_trained_model} --epoch={epoch}

Sampling data

You can generate the training images for visualization by simply running:

cd data

python sample_{env_name}_data.py --sample_size={sample_size} --noise={noise}

Currently the code supports simulating 3 environments: planar, pendulum and cartpole.

The raw data (images) is saved in data/{env_name}/raw_{noise}_noise

Running iLQR on latent space

The configuration file for running iLQR for each task is in ilqr_config folder, you can modify with your own settings. Run python ilqr.py --task={task}, where task is in {plane, swing, balance, cartpole}.

The code will run iLQR for all models trained for that specific task and compute some statistics. The result is saved in iLQR/result.

Result

We evaluate the PCC model in 2 ways: quality of the latent map and the percentage of time the agent spent in the goal region.

Planar system

Latent map

Below is a random latent map PCC produces. You can watch a video clip comparing how latent maps produced by E2C and PCC evolve at this link: https://www.youtube.com/watch?v=pBmzFvvE2bo.

Latent space learned by PCC

Control result

We got around 48% on average and around 76% for the best model. Below are 2 sample trajectories of the agent.

Sample planar trajectory 1

Sample planar trajectory 2

Inverted pendulum

Latent map

Below is a random latent map PCC produces.

Latent space learned by PCC

Control result

We got around 60.7% on average and around 80.65% for the best model. Below are 2 sample trajectories of the inverted pendulum.

Sample inverted pendulum trajectory 1

Sample inverted pendulum trajectory 2

Cartpole

Sample cartpole trajectory 1

Sample cartpole trajectory 2

Acknowledgment

Many thanks to Nir Levine and Yinlam Chow for their help in answering the questions related to the PCC paper.

Citation

If you find this implementation useful for your work, please consider starring this repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].