Coder Social home page Coder Social logo

hardianlawi / mtl-homoscedastic-uncertainty Goto Github PK

View Code? Open in Web Editor NEW
52.0 5.0 12.0 29 KB

Multi Task Learning Implementation with Homoscedastic Uncertainty in Tensorflow

Jupyter Notebook 70.84% Python 29.16%
neural-network tensorflow multi-task-learning estimator uncertainty deep-learning uncertainties homoscedastic homoskedastic

mtl-homoscedastic-uncertainty's Introduction

Multi Task Learning with Homoscedastic Uncertainty

Multi Task Learning has been widely used in different applications. However, the performance of the model heavily depends on the method used to combine the losses between various objectives. This repository contains the implementation of https://arxiv.org/abs/1705.07115 in Tensorflow.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

You need to install the libraries below:

numpy
pandas
tensorflow
scikit-learn

Scripts

Below are the functions of the scripts:

  • config.py: contains the hyperparameters of the model and the configuration for the training such as the labels used as the objectives.
  • estimators.py: contains the neural networks that import the hyperparameters and the configuration from config.py and train an estimator which then would be exported to a SavedModel format.

Training

To train your model, you will need to have a file containing your dataset which includes both features and labels. Then, run the command below:

python estimators.py [--train_data] [--model_path]

Arguments:

--train_data : path to the dataset
--model_path : directory to store the outputs.

Example:

python estimators.py --train_data ~/Downloads/train.csv --model_path /tmp/model-v1.0.0

Evaluation

For evaluation, we have amazing tool called tensorboard built by tensorflow developers to help us observe the training progress or even debug our network. You can run the command below:

tensorboard [--logdir] [--host optional] [--port optional]

Argument:

--logdir : the directory used to store the outputs during the training.
--host : ip address of the machine
--port : port you want to serve on.

Inference

For inference, you could load the exported SavedModel and do an inference like below:

import json
from tensorflow.contrib import predictor
from sklearn.externals import joblib


# Read configuration of training
with open("../model_config.json", 'r') as f:
    params = json.load(f)

# Load scikit learn preprocessor
preprocessor = joblib.load('../preprocessor.pkl')

# Load tensorflow predictor
predict_fn = predictor.from_saved_model(MODEL_PATH + 'goboard/' + model_name)

# Suppose xTest is a 2D numpy array
inference_x = {'x': xTest}

# Generate predictions
predictions = predict_fn(inference_x)['output']

Deployment

After training the model in Python, tensorflow serving could be used to deploy the model.

Authors

Acknowledgments

Please read the paper for more details of the model or check the github of one of the authors github for the implementation in keras.

Additional References

mtl-homoscedastic-uncertainty's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mtl-homoscedastic-uncertainty's Issues

binary cross entropy loss function

Hi, @hardianlawi !
I have referenced you code in my click-through rate prediction project.
However, one of my task could not converge and I have a question about the inconsistency regarding the binary cross entropy loss function and your implementation.
image
The loss function has added by the log of each task's theta, but you didn't include it in your implementation here:

specific_loss = tf.nn.sigmoid_cross_entropy_with_logits(

Shape of weight variables

Is the shape of the variable = []?
It is [1,] in the author's implementation and it works fine on another example with shape= [1,] but it does not work with shape=[]

Possible bug in binary classification logits in MTL estimator

In L118 it you update the the logit dictionary with logits[target_name] = logits[target_name]/uncertainties[target_name]

You later do this again when computing the task specific loss for binary classification
specific_loss = tf.nn.sigmoid_cross_entropy_with_logits( labels=labels[target_name], logits=logits[target_name]/uncertainties[target_name], )

Example training file

Could you provide some example files for the training of the network? It seems like it's expecting a CSV file that will provide the full paths to the training images, correct? I would appreciate if you could send me also any other additional but needed file. Thank you for your time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.