Giter Site home page Giter Site logo

dl-selection's Introduction

Deep learning feature selection

The dl-selection repository contains tools for performing feature selection with deep learning models. It currently has four mechanisms for selecting features, each of which relies on a stochastic relaxation of the feature selection problem. Each mechanism is a learnable input layer that determines which features to select throughout the course of training.

1. Concrete Mask: selects a user-specified number of features k by learning a k-hot vector m for element-wise multiplication with the input x. The layer is composed with a separate network that learns to make predictions using the masked input x * m.

2. Concrete Selector: selects a user-specified number of features k by learning a binary matrix M that selects features from x. The layer is composed with a separate network that learns to make predictions using the selected features Mx.

3. Concrete Gates: selects features subject to a L0 penalty by learning binary gates m1, m2, ... for each feature. The layer is composed with a separate network that learns to make predictions using the masked input x * m.

4. Concrete Max: selects a user-specified number of features k by learning a Categorical distribution over (1, 2, ..., d) from which features are sampled. The most probable features are selected after training.

Usage

The module selection.models implements a class SelectorMLP for automatically creating a model that composes the user-specified input layer with a prediction network. The model has a built-in train method, so it can be used like this:

import torch.nn as nn
from selection import models

# Load data
train_dataset, val_dataset = ...
input_size, output_size = ...

# Set up model
model = models.SelectorMLP(
    input_layer='concrete_mask',
    k=20,
    input_size=input_size,
    output_size=output_size,
    hidden=[512, 512],
    activation='elu')

# Train model
model.learn(
    train_dataset,
    val_dataset,
    lr=1e-3,
    mbsize=64,
    max_nepochs=300,
    start_temperature=10.0,
    end_temperature=0.01,
    loss_fn=nn.CrossEntropyLoss())

# Extract selected indices
inds = model.get_inds()

Check out the mnist selection.ipynb notebook for examples of how to use each of the layers.

Installation

The easiest way to install this package is with pip:

pip install dl-selection

Or, you can clone the repository to get the most recent version of the code.

Authors

dl-selection's People

Contributors

iancovert avatar

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.