dimanche 9 février 2020

Keras - Reflective padding

Is there a way to use reflective padding in Keras or a way to integrate TensorFlow reflect pad method? I tried to use the code from this post: Reflection padding Conv2D

and the error I get is: TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

My code:

def conv_layer(x, channels,kernel_size,dilation_rate, name="conv"):
    """A single convolutional layer."""
    conv = layers.Conv2D(channels, kernel_size,
                             padding='valid', # should be 'same' but using 'valid' for testing purposes'
                             dilation_rate=dilation_rate,
                             kernel_regularizer=regul(),
                             kernel_initializer='RandomNormal',
                             bias_initializer=get_bias_init(),
                             name=name)
    x = ReflectionPadding2D(x)
    #y=layers.Dropout(0.3)(x)
    y = prelu(conv(x), name=name)
    y=layers.BatchNormalization(name=name+'_b_norm')(y)
    concat=concat_layer(x,y,name=name+'/concat')

    return concat




Aucun commentaire:

Enregistrer un commentaire