ai: add missing gamma layer

This commit is contained in:
Starbeamrainbowlabs 2022-08-31 18:52:35 +01:00
parent 51cf08a386
commit e4edc68df5
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -0,0 +1,20 @@
import tensorflow as tf
# Code from https://github.com/leanderme/ConvNeXt-Tensorflow/blob/main/ConvNeXt.ipynb
class LayerConvNeXtGamma(tf.keras.layers.Layer):
def __init__(self, const_val = 1e-6, dim = None, name=None, **kwargs):
super(LayerConvNeXtGamma, self).__init__(name=name)
self.dim = dim
self.const = const_val * tf.ones((self.dim))
def call(self, inputs, **kwargs):
return tf.multiply(inputs, self.const)
def get_config(self):
config = super(LayerConvNeXtGamma, self).get_config()
config.update({ "const": self.const, "dim": self.dim })
return config