there is a great introduction of how to create custom layers in tensorflow.
An example, taken from the documentation, would be
class MyDenseLayer(tf.ke