• Stars
    star
    107
  • Rank 323,587 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Tensorflow implementation of Representation Learning by Learning to Count

Representation Learning by Learning to Count in Tensorflow

As part of the implementation series of Joseph Lim's group at USC, our motivation is to accelerate (or sometimes delay) research in the AI community by promoting open-source projects. To this end, we implement state-of-the-art research papers, and publicly share them with concise reports. Please visit our group github site for other projects.

This project is implemented by Shao-Hua Sun and the codes have been reviewed by Te-Lin Wu before being published.

Descriptions

This project is a Tensorflow implementation of Representation Learning by Learning to Count. This paper proposes a novel framework for representation learning, where we are interested in learning good representations of visual content, by utilizing the concept of counting visual primitives.

In particular, it exploits the fact that the number of visual primitives presented in an image should be invariant to transformations such as scaling, rotation, etc. Given this fact, the model is able to learn meaningful representations by minimizing a contrastive loss where we enforce that the counting feature should be different between a pair of randomly selected images. During the fine-tuning phase, we train a set of linear classifiers to perform an image classification task on ImageNet based on learned representations to verify the effectiveness of the proposed framework. An illustration of the proposed framework is as follows.

The implemented model is trained and tested on ImageNet.

Note that this implementation only follows the main idea of the original paper while differing a lot in implementation details such as model architectures, hyperparameters, applied optimizer, etc. For example, the implementation adopts the VGG-19 architecture instead of AlexNet which is used in the origianl paper.

*This code is still being developed and subject to change.

Prerequisites

Usage

Datasets

The ImageNet dataset is located in the Downloads section of the website. Please specify the path to the downloaded dataset by changing the variable __IMAGENET_IMG_PATH__ in datasets/ImageNet.py. Also, please provide a list of file names for trainings in the directory __IMAGENET_LIST_PATH__ with the file name train_list.txt. By default, the train_list.txt includes all the training images in ImageNet dataset.

Train the models

Train models with downloaded datasets. For example:

$ python trainer.py --prefix train_from_scratch --learning_rate 1e-4 --batch_size 8

Fine-tune the models

Train models with downloaded datasets. For example:

$ python trainer_classifier.py --prefix fine_tune --learning_rate 1e-5 --batch_size 8 --checkpoint train_dir/train_from_scratch-ImageNet_lr_0.003-20170828-172936/model-10001

Note that you must specify a checkpoint storing the pretrained model. Also, linear classifiers are applied to all the features including conv1, conv2, ..., fc1, fc2, ..., etc, coming from the pretrained model with the same learning rate, optimizers, etc. To fine tune the model only with a certain feature, please specify it in the code model_classifier.py.

Test the fine-tuned models

$ python evaler.py --checkpoint train_dir/fine_tune-ImageNet_lr_0.0001-20170915-172936/model-10001

Train and test your own datasets:

  • Create a directory
$ mkdir datasets/YOUR_DATASET
  • Create a input helper datasets/YOUR_DATASET.py following the format of datasets/ImageNet.py
  • Specify the path ot the image and the list of file names.
  • Modify trainer.py.
  • Finally, train and test your models
$ python trainer.py --dataset YOUR_DATASET
$ python trainer_classifier.py --dataset YOUR_DATASET --checkpoint train_dir/train_from_scratch-YOUR_DATASET_lr_0.003-20170828-172936/model-10001
$ python evaler.py --dataset YOUR_DATASET --checkpoint train_dir/fine_tune-YOUR_DATASET_lr_0.0001-20170915-172936/model-10001

Training details

Learning the representations

Related works

Author

Shao-Hua Sun / @shaohua0116 @ Joseph Lim's research lab @ USC

More Repositories

1

awesome-rl-envs

1,064
star
2

SSGAN-Tensorflow

A Tensorflow implementation of Semi-supervised Learning Generative Adversarial Networks (NIPS 2016: Improved Techniques for Training GANs).
Python
514
star
3

furniture

IKEA Furniture Assembly Environment for Long-Horizon Complex Manipulation Tasks
Python
497
star
4

Relation-Network-Tensorflow

Tensorflow implementations of Relational Networks and a VQA dataset named Sort-of-CLEVR proposed by DeepMind.
Python
321
star
5

ACGAN-PyTorch

Python
264
star
6

spirl

Official implementation of "Accelerating Reinforcement Learning with Learned Skill Priors", Pertsch et al., CoRL 2020
Python
186
star
7

furniture-bench

FurnitureBench: Real-World Furniture Assembly Benchmark (RSS 2023)
Python
129
star
8

BicycleGAN-Tensorflow

A Tensorflow implementation of BicycleGAN.
Python
101
star
9

Generative-Latent-Optimization-Tensorflow

Tensorflow implementation of Generative Latent Optimization (GLO) proposed by Facebook AI Research
Python
96
star
10

mopa-rl

Motion Planner Augmented Reinforcement Learning for Robot Manipulation in Obstructed Environments (CoRL 2020)
Python
70
star
11

MAML-tf

Tensorflow Implementation of MAML
Python
52
star
12

skimo

Skill-based Model-based Reinforcement Learning (CoRL 2022)
Python
50
star
13

coordination

Learning to Coordinate Manipulation Skills via Skill Behavior Diversification (ICLR 2020)
Python
43
star
14

leaps

Code for Learning to Synthesize Programs as Interpretable and Generalizable Policies in NeurIPS 2021
Python
33
star
15

FeatureControlHRL-Tensorflow

A Tensorflow implementation of Feature Control as Intrinsic Motivation for Hierarchical Reinforcement Learning
Python
32
star
16

skill-chaining

Adversarial Skill Chaining for Long-Horizon Robot Manipulation via Terminal State Regularization (CoRL 2021)
Python
28
star
17

CycleGAN-Tensorflow

A Tensorflow implementation of Cycle-Consistent Adversarial Networks.
Python
26
star
18

new-actions-rl

Jupyter Notebook
23
star
19

goal_prox_il

Generalizable Imitation Learning from Observation via Inferring Goal Proximity (NeurIPS 2021)
Python
22
star
20

skild

Python
21
star
21

i2a-tf

Imagination Augmented Agents in TensorFlow
Python
20
star
22

boss

Code for the paper Bootstrap Your Own Skills: Learning to Solve New Tasks with Large Language Model Guidance, accepted to CoRL 2023 as an Oral Presentation.
Python
18
star
23

create

CREATE Environment for long-horizon physics-puzzle tasks with diverse tools
Python
17
star
24

agile

Official implementation of "Know Your Action Set: Learning Action Relations for Reinforcement Learning", Jain et al., ICLR 2022.
Python
16
star
25

clvr_jaco_play_dataset

Official release of the CLVR Jaco Play Dataset, Dass et al. 2023
Shell
10
star
26

sprint

Code and website for for SPRINT: Scalable Policy Pre-Training via Language Instruction Relabeling
Python
10
star
27

DiscoGAN-Tensorflow

A Tensorflow implementation of DiscoGAN.
Python
8
star
28

tarp

Official implementation of "Task-Induced Representation Learning", Yamada et al., ICLR 2022
Python
8
star
29

idapt

Policy Transfer across Visual and Dynamics Domain Gaps via Iterative Grounding (RSS 2021)
Python
8
star
30

mopa-pd

Distilling Motion Planner Augmented Policies into Visual Control Policies for Robot Manipulation (CoRL 2021)
Python
6
star