Ejemplo n.º 1
0
def conv(x,
         num_filters,
         filter_size=4,
         stride=2,
         padding=1,
         name=None,
         act=None):
    if name is None:
        name = get_parent_function_name()
    # return fluid.nets.simple_img_conv_pool(
    #     input=x,
    #     filter_size=4,
    #     num_filters=num_filters,
    #     pool_size=2,
    #     pool_stride=2,
    #     param_attr=name + 'w',
    #     bias_attr=name + 'b',
    #     use_cudnn=use_cudnn,
    #     act=act)
    return fluid.layers.conv2d(input=x,
                               filter_size=4,
                               num_filters=num_filters,
                               stride=stride,
                               padding=padding,
                               param_attr=name + 'w',
                               bias_attr=name + 'b',
                               act=act)
Ejemplo n.º 2
0
def fc(x, num_filters, name=None, act=None):
    if name is None:
        name = get_parent_function_name()
    return fluid.layers.fc(input=x,
                           size=num_filters,
                           act=act,
                           param_attr=name + 'w',
                           bias_attr=name + 'b')
Ejemplo n.º 3
0
def bn(x, name=None, act='relu'):
    if name is None:
        name = get_parent_function_name()
    #return fluid.layers.leaky_relu(x)
    return fluid.layers.batch_norm(x,
                                   param_attr=name + '1',
                                   bias_attr=name + '2',
                                   moving_mean_name=name + '3',
                                   moving_variance_name=name + '4',
                                   name=name,
                                   act=act)
Ejemplo n.º 4
0
def conv(x, num_filters, name=None, act=None):
    if name is None:
        name = get_parent_function_name()
    return fluid.nets.simple_img_conv_pool(input=x,
                                           filter_size=5,
                                           num_filters=num_filters,
                                           pool_size=2,
                                           pool_stride=2,
                                           param_attr=name + 'w',
                                           bias_attr=name + 'b',
                                           use_cudnn=use_cudnn,
                                           act=act)
Ejemplo n.º 5
0
def deconv(x,
           num_filters,
           name=None,
           filter_size=5,
           stride=2,
           dilation=1,
           padding=2,
           output_size=None,
           act=None):
    if name is None:
        name = get_parent_function_name()
    return fluid.layers.conv2d_transpose(input=x,
                                         param_attr=name + 'w',
                                         bias_attr=name + 'b',
                                         num_filters=num_filters,
                                         output_size=output_size,
                                         filter_size=filter_size,
                                         stride=stride,
                                         dilation=dilation,
                                         padding=padding,
                                         use_cudnn=use_cudnn,
                                         act=act)