Skip to content

tensorflow keras layers for Spectral Normalization, available on CPU, GPU and TPU.

License

Notifications You must be signed in to change notification settings

mgmk2/SpectralNormalization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SpectralNormalization

Implementation of Spectral Normalization for TensorFlow keras API. This layers are available on Distribute Strategy (ex. TPU).

This is a modification of TensorFlow keras layers and code is derived from TensorFlow ver1.14 (under Apache License 2.0).

Features

TensorFlow keras layers class with spectral normalization:

  • SNDense
  • SNConv1D
  • SNConv2D
  • SNConv3D

Requirement

  • tensorflow >= 1.14
  • numpy (only used in test code)

Usage

Replace keras layers (Conv2D etc) with spectral normalization layers as below:

from SpectralNormalization.layers import SNConv2D

# 2D convolution with spectral normalization
outputs = SNConv2D(64, (3, 3), padding='same')(inputs)

You can set singular_vector_initializer and power_iter arguments, which affect singular value estimation in spectral normalization. And also, you can use the same arguments as original keras layers.

Tests

You can test singular vector estimation, gradient calculation and singular vector assignment:

$cd layers
$python test.py

Also you can test them on colab TPU:

$cd layers
$python test.py --use_tpu

License

Apache License 2.0

About

tensorflow keras layers for Spectral Normalization, available on CPU, GPU and TPU.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages