Giter Club home page Giter Club logo

targeted-dropout's Introduction

Targeted Dropout

Aidan N. Gomez, Ivan Zhang, Kevin Swersky, Yarin Gal, and Geoffrey E. Hinton

Table of Contents

Requirements

  • Python 3
  • Tensorflow 1.8

Quick Start

  1. Train a model: python -m TD.train --hparams=resnet_default
  2. Prune that model: python -m TD.scripts.prune.eval --hparams=resnet_default --prune_percent 0.0,0.25,0.5,0.75,0.95

Flags

  • --env: one of local, gcp (GPU instances), or tpu (TPU instances). Feel free to add more if necessary.
  • --hparams: the hparam set you want to run.
  • --hparam_override: manually specify hparams to be overridden (e.g --hparam_override 'drop_rate=0.66')

targeted-dropout'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  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  avatar

targeted-dropout's Issues

where can I call the function of targeted dropout?

Hello,Think you for your work,I successfully define your targeted dropout'function according your help.In order to let this function work,But now I do not know where can I call this function in my model .
Because dropout in fully-connection layer,is targeted dropout only in fully-connection layer?except for you reply

Targeted Units Dropout - Why dropout also on test?

I saw that the targeted dropout on the weights can either select train or test mode, instead the targeted dropout on the units is always on train mode even when the model does the inference. Is there any reason for that?

  • Targeted Weight Dropout Function:

def targeted_weight_dropout(w, params, is_training):
    drop_rate = params.drop_rate
    targ_perc = params.targ_rate
    w_shape = w.shape
    w = tf.reshape(w, [-1, w_shape[-1]])
    norm = tf.abs(w)
    idx = tf.to_int32(targ_perc * tf.to_float(tf.shape(w)[0]))
    threshold = tf.contrib.framework.sort(norm, axis=0)[idx]
    mask = norm < threshold[None, :]
    if not is_training:
        w = (1. - tf.to_float(mask)) * w
        w = tf.reshape(w, w_shape)
        return w
    mask = tf.to_float(
        tf.logical_and(tf.random_uniform(tf.shape(w)) < drop_rate, mask))
    w = (1. - mask) * w
    w = tf.reshape(w, w_shape)
    return w

https://github.com/for-ai/TD/blob/87cf2a0682274badbfde962023c657779aa79975/models/utils/dropouts.py#L23

  • Targeted Unit Dropout Function:

def targeted_unit_dropout(x, params, is_training):
        w = tf.reshape(x, [-1, x.shape[-1]])
        norm = tf.norm(w, axis=0)
        idx = int(params.targ_rate * int(w.shape[1]))
        sorted_norms = tf.contrib.framework.sort(norm)
        threshold = sorted_norms[idx]
        mask = (norm < threshold)[None, :]
        mask = tf.tile(mask, [w.shape[0], 1])
        mask = tf.where(
                tf.logical_and((1. - params.drop_rate) < tf.random_uniform(tf.shape(w)),
                mask), tf.ones_like(w, dtype=tf.float32),
                tf.zeros_like(w, dtype=tf.float32))
        x = tf.reshape((1 - mask) * w, x.shape)
        return x

https://github.com/for-ai/TD/blob/87cf2a0682274badbfde962023c657779aa79975/models/utils/dropouts.py#L217

How embed your targeted dropout in other model?

Hello,think you for your code about the parper of targeted dropout,I see you said It is simultaneously easy to implement, consisting of a two-line change using neural network frameworks such as Tensorflow,I want to which line need to change?How embed your targeted dropout in other model?Expect for your reply。

TypeError: bad operand type for unary -: 'TopKV2'

Thank you for your reply.I successfully put your code in my model,but when I call the function of targeted dropout,I meet a problem, the problem is:
TypeError: bad operand type for unary -: 'TopKV2'
can you help me solve this problem?my these code is that:

image
image

Variational_dropout and variational_unit_dropout

Hello, I' m confused by the difference between variational_dropout and variational_unit_dropout because I think they are the same through the program. I will be very grateful if you can explain it for me.

ResNet-32 architecture doesn't match ResNet paper

The hparams for ResNet-32 seem to define an input layer with 16 filters followed by stacks of layers with 32, 64, and then 128 filters:
https://github.com/for-ai/TD/blob/master/hparams/resnet.py#L12

This doesn't match the ResNet paper, which defines ResNet-32 with CIFAR-10 as having an input layer of 16 filters followed by stacks of layers with 16, 32, and 64 filters:

image

Also, the pruning code reports a total of 1 857 498 parameters, much more than the 0.46M reported in the paper. Changing hps.residual_filters to [16, 16, 32, 64] gives me a much closer value of 468 890 parameters.

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.