Spectral Normalization implemented as Tensorflow 2.0
- Convert simple conv2d model to DCGAN model
This is currently a test code using a simple image classification model.
python main.py
- Sequential API
from sn import SpectralNormalization
model = models.Sequential()
model.add(SpectralNormalization(layers.Conv2D(32, (3, 3), activation='relu')))
...
- Functional API
from sn import SpectralNormalization
inputs = layers.Input(shape=(28,28,1))
x = SpectralNormalization(layers.Conv2D(32, (3, 3), activation='relu'))(inputs)
...
- Custom Layer Method
from sn import SpectralNormalization
class CustomLayer(tf.keras.layers.Layer):
def __init__(self):
self.conv2DSN = SpectralNormalization(layers.Conv2D(32, (3, 3), activation='relu'))
...
def call(self, inputs):
x = self.conv2DSN(inputs)
...