TensorFlow.NET icon indicating copy to clipboard operation
TensorFlow.NET copied to clipboard

How to use BatchNormalization with tf.keras

Open JulietteV opened this issue 6 years ago • 2 comments

Hello, I'm trying to translate a Python Unet architecture into Tensorflow.NET using tf.keras but I don't find how to transpose this piece of Python code into C# :

def conv2d_block(input_tensor, n_filters, kernel_size=3, batchnorm=True):
    # first layer
    x = Conv2D(filters=n_filters, kernel_size=(kernel_size, kernel_size), kernel_initializer="he_normal",
               padding="same")(input_tensor)
    if batchnorm:
        x = BatchNormalization()(x)
    x = Activation("relu")(x)
    # second layer
    x = Conv2D(filters=n_filters, kernel_size=(kernel_size, kernel_size), kernel_initializer="he_normal",
               padding="same")(x)
    if batchnorm:
        x = BatchNormalization()(x)
    x = Activation("relu")(x)
    return x

In particular I don't understand how to use BatchNormalization in C#.

Can you help me ?

JulietteV avatar Oct 21 '20 10:10 JulietteV

tf.layers.batch_normalization has not been tested yet.

Oceania2018 avatar Oct 24 '20 13:10 Oceania2018

@JulietteV It's available in TensorFlow.Keras v0.2.1

Esther2013 avatar Dec 21 '20 17:12 Esther2013