All Projects → gstrezoski → TaskRouting

gstrezoski / TaskRouting

Licence: other
(ICCV 2019 Oral) Many Task Learning With Task Routing http://openaccess.thecvf.com/content_ICCV_2019/html/Strezoski_Many_Task_Learning_With_Task_Routing_ICCV_2019_paper.html

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to TaskRouting

event-embedding-multitask
*SEM 2018: Learning Distributed Event Representations with a Multi-Task Approach
Stars: ✭ 22 (-63.93%)
Mutual labels:  multitask, multitask-learning
YOLOP
You Only Look Once for Panopitic Driving Perception.(https://arxiv.org/abs/2108.11250)
Stars: ✭ 1,228 (+1913.11%)
Mutual labels:  multitask-learning
SGDepth
[ECCV 2020] Self-Supervised Monocular Depth Estimation: Solving the Dynamic Object Problem by Semantic Guidance
Stars: ✭ 162 (+165.57%)
Mutual labels:  multitask-learning
JointIDSF
BERT-based joint intent detection and slot filling with intent-slot attention mechanism (INTERSPEECH 2021)
Stars: ✭ 55 (-9.84%)
Mutual labels:  multitask-learning
MTL-AQA
What and How Well You Performed? A Multitask Learning Approach to Action Quality Assessment [CVPR 2019]
Stars: ✭ 38 (-37.7%)
Mutual labels:  multitask-learning
Soft-Module
Code for "Multi-task Reinforcement Learning with Soft Modularization"
Stars: ✭ 71 (+16.39%)
Mutual labels:  multitask-learning
AuxiLearn
Official implementation of Auxiliary Learning by Implicit Differentiation [ICLR 2021]
Stars: ✭ 71 (+16.39%)
Mutual labels:  multitask-learning
dnn.cool
A framework for multi-task learning, where you may precondition tasks and compose them into bigger tasks. Conditional objectives and per-task evaluations and interpretations.
Stars: ✭ 44 (-27.87%)
Mutual labels:  multitask-learning
GEANet-BioMed-Event-Extraction
Code for the paper Biomedical Event Extraction with Hierarchical Knowledge Graphs
Stars: ✭ 52 (-14.75%)
Mutual labels:  multitask-learning
ChineseNER
中文NER的那些事儿
Stars: ✭ 241 (+295.08%)
Mutual labels:  multitask-learning
Decanlp
The Natural Language Decathlon: A Multitask Challenge for NLP
Stars: ✭ 2,255 (+3596.72%)
Mutual labels:  multitask-learning
Awesome-Multi-Task-Learning
A list of multi-task learning papers and projects.
Stars: ✭ 230 (+277.05%)
Mutual labels:  multitask-learning
mtlearn
Multi-Task Learning package built with tensorflow 2 (Multi-Gate Mixture of Experts, Cross-Stitch, Ucertainty Weighting)
Stars: ✭ 45 (-26.23%)
Mutual labels:  multitask-learning
CS330-Stanford-Deep-Multi-Task-and-Meta-Learning
My notes and assignment solutions for Stanford CS330 (Fall 2019 & 2020) Deep Multi-Task and Meta Learning
Stars: ✭ 34 (-44.26%)
Mutual labels:  multitask-learning
Recurrent Interaction Network EMNLP2020
Here is the code for the paper ``Recurrent Interaction Network for Jointly Extracting Entities and Classifying Relations'' accepted by EMNLP2020.
Stars: ✭ 13 (-78.69%)
Mutual labels:  multitask-learning

Many Task Learning With Task Routing - [ICCV'19 Oral]

This is the official implementation repo for our 2019 ICCV paper Many Task Learning With Task Routing:

Many Task Learning With Task Routing
Gjorgji Strezoski, Nanne van Noord, Marcel Worring
International Conference on Computer Vision (ICCV), 2019 [Oral]
[CVF] [ArXiv] [Web]

It contains the Task Routing Layer implentation, its integration in existing models and usage instructions.


Figure 1

Abstract: Typical multi-task learning (MTL) methods rely on architectural adjustments and a large trainable parameter set to jointly optimize over several tasks. However, when the number of tasks increases so do the complexity of the architectural adjustments and resource requirements. In this paper, we introduce a method which applies a conditional feature-wise transformation over the convolutional activations that enables a model to successfully perform a large number of tasks. To distinguish from regular MTL, we introduce Many Task Learning (MaTL) as a special case of MTL where more than 20 tasks are performed by a single model. Our method dubbed Task Routing (TR) is encapsulated in a layer we call the Task Routing Layer (TRL), which applied in an MaTL scenario successfully fits hundreds of classification tasks in one model. We evaluate on 5 datasets and the Visual Decathlon (VD) challenge against strong baselines and state-of-the-art approaches.


Usage

Task Routing Layer

In taskrouting.py you can find the Task Routing Layer source. It is a standalone file containing the PyTorch layer class. It takes 3 input arguments for instantiation:

  • unit_count (int): Number of input channels going into the Task Routing layer (TRL).
  • task_count (int): Number of tasks. (In Single Task Learning it applies to number of output classes)
  • sigma (float): Ratio for routed units per task. (0.5 is default)

Sample Model

In routed_vgg.py you can find an implementation of the stock PyTorch VGG-11 model with or without BatchNorm converted for brahnched MTL. With:

for ix in range(self.task_count):
  self.add_module("classifier_" + str(ix), nn.Sequential(
  nn.Linear(1024 * bottleneck_spatial[0] * bottleneck_spatial[1], 2)
  ))

we create as many task specific branches as there are tasks. Additionally, the forward function is designed to forward the data through the active task branch only.

In the code snippet (lines 71 to 74 from routed_vgg.py) below we add the TRL to the VGG net:

conv2d = nn.Conv2d(in_channels, v, kernel_size=3, padding=1)
router = TaskRouter(v, task_count, int(v * sigma), "taskrouter_"+str(ix))
if batch_norm:
   layers += [conv2d, nn.BatchNorm2d(v), router, nn.ReLU(inplace=True)]

For training a model with the Task Routing Layer, the active model task needs to be randomly changed over the training itterations within an epoch. For example:

def change_task(m):
    if hasattr(m, 'active_task'):
        m.set_active_task(active_task)


def train(args, model, task_count, device, train_loader, optimizer, criterion, epoch, total_itts):

    train_start = time.time()
    model.train()

    correct, positives, true_positives, score_list = initialize_evaluation_vars()

    epoch_loss = 0
    individual_loss = [0 for i in range(task_count)]

    for enum_return in enumerate(train_loader):

        batch_idx = enum_return[0]
        data = enum_return[1][0]
        targets = enum_return[1][1:]

        data = data.to(device)
        
        for ix in sample(range(task_count), 1):
            target = targets[ix].to(device)
            global active_task
            active_task = ix

            model = model.apply(change_task)
            out = model(data)
            labels = target[:, ix]
            train_loss = criterion(out, labels)
            optimizer.zero_grad()
            train_loss.backward()
            optimizer.step()

    train_end = time.time()
    print("Execution time:", train_end - train_start, "s.")

    return total_itts

If you find this repository usefull, please cite this paper:

@article{strezoski2019taskrouting,
title={Many Task Learning With Task Routing},
author={Strezoski, Gjorgji and van Noord, Nanne and Worring, Marcel},
booktitle = {International Conference on Computer Vision (ICCV)},
organization={IEEE}
year={2019},
url={https://arxiv.org/abs/1903.12117}
}
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].