Skip to content

Keras implementation of a gradient reversal layer for the Tensorflow backend

License

Notifications You must be signed in to change notification settings

michetonu/gradient_reversal_keras_tf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Gradient Reversal Layer for Keras

Keras implementation of a gradient inversion layer for the Tensorflow backend, following the paper Domain-Adversarial Training of Neural Networks. Modified the Theano version by Pumpikano found here, expanding on the work done by VanushVaswani found here.

The layer can be placed in a Functional model such as:

Flip = flipGradientTF.GradientReversal(hp_lambda)
dann_in = Flip(previous_layer_output)
dann_out = Dense(2)(dann_in)

where hp_lambda is the constant which multiplies the flipped gradient.

An example of a model where this is implemented (with full code) can be found here: https://github.com/michetonu/DA-RNN_manoeuver_anticipation

Requirements

Works only with Tensorflow < 2.0.0! See here for alternative solutions with TF2 https://stackoverflow.com/questions/56841166/how-to-implement-gradient-reversal-layer-in-tf-2-0

About

Keras implementation of a gradient reversal layer for the Tensorflow backend

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages