Keras.NET
Keras.NET copied to clipboard
No tf.keras.layers.layer class ?
I want to translate this python code to C#
class ReflectionPadding2D(tf.keras.layers.Layer):
def __init__(self, padding=(1, 1), **kwargs):
self.padding = tuple(padding)
self.input_spec = [tf.keras.layers.InputSpec(ndim=4)]
super(ReflectionPadding2D, self).__init__(**kwargs)
def compute_output_shape(self, s):
return (s[0], s[1] + 2 * self.padding[0], s[2] + 2 * self.padding[1], s[3])
def call(self, x, mask=None):
w_pad, h_pad = self.padding
return tf.pad(x, [[0, 0], [h_pad, h_pad], [w_pad, w_pad], [0, 0]], 'REFLECT')
def get_config(self):
config = super().get_config().copy()
return config
This class inherit from tf.heras.layers.layer but there is no such class in Tensorflow.NET. And i aslo notice that there is 1 class name BaseLayer in the Keras.Layers namespace. So tf.keras.layers.layer and Keras.Layers.Layer are the same class ? If so can u show me how to rewrite the custom layer above in C#. Thank you for all of your answer