Skip to content

Commit

Permalink
【fluid api clear】Move batch norm1 (PaddlePaddle#47965)
Browse files Browse the repository at this point in the history
* modify slice infershape

* code style

* modify slice_unittest

* temp fix

* batch_norm api move

* code_style

* codestyle

* ci_static

* add __init__

* reset other change

* revert .cc

* add import batchnorm

* conflict and revert

* fix bug

* fix third conflict one day

* fix conflict

* fix conflict bug

* fix conflict bug

* modify api

* code_style

* modify doc

* add lost doc stable

* fix conflict bug

* ci lack of gpu
  • Loading branch information
xiaoguoguo626807 committed Dec 7, 2022
1 parent d4fb5de commit 9733913
Show file tree
Hide file tree
Showing 66 changed files with 450 additions and 428 deletions.
5 changes: 4 additions & 1 deletion python/paddle/fluid/contrib/layers/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1963,8 +1963,11 @@ def fused_bn_add_act(
Examples:
.. code-block:: python
import paddle
import paddle.fluid as fluid
paddle.enable_static()
# required: gpu
def build_program(main_program, startup_program):
with fluid.program_guard(main_program, startup_program):
x = fluid.layers.data(name='x', shape=[1, 28, 28], dtype='float32')
Expand All @@ -1987,7 +1990,7 @@ def build_program(main_program, startup_program):
act=None,
bias_attr=False,
data_format='NHWC')
bn = fluid.layers.batch_norm(
bn = paddle.static.nn.batch_norm(
input=conv1_1,
act=None,
data_layout='NHWC')
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/fluid/contrib/slim/tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def conv_block():
pool_stride=2,
act="relu",
)
conv_pool_1 = fluid.layers.batch_norm(conv_pool_1)
conv_pool_1 = paddle.static.nn.batch_norm(conv_pool_1)
conv_pool_2 = fluid.nets.simple_img_conv_pool(
input=conv_pool_1,
filter_size=5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def conv_net(img, label):
pool_stride=2,
act="relu",
)
conv_pool_1 = fluid.layers.batch_norm(conv_pool_1)
conv_pool_1 = paddle.static.nn.batch_norm(conv_pool_1)
conv_pool_2 = fluid.nets.simple_img_conv_pool(
input=conv_pool_1,
filter_size=5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def conv_bn_layer(
act=None,
bias_attr=bias_attr,
)
return fluid.layers.batch_norm(input=tmp, act=act)
return paddle.static.nn.batch_norm(input=tmp, act=act)

data = fluid.layers.data(
name='image',
Expand Down Expand Up @@ -102,7 +102,7 @@ def conv_net(img, label, quant_skip_pattern):
pool_type='max',
act="relu",
)
conv_pool_1 = fluid.layers.batch_norm(conv_pool_1)
conv_pool_1 = paddle.static.nn.batch_norm(conv_pool_1)
conv_pool_2 = fluid.nets.simple_img_conv_pool(
input=conv_pool_1,
filter_size=5,
Expand Down Expand Up @@ -712,7 +712,7 @@ def conv_bn_layer(
act=None,
bias_attr=bias_attr,
)
return fluid.layers.batch_norm(input=tmp, act=act)
return paddle.static.nn.batch_norm(input=tmp, act=act)

data1 = fluid.layers.data(name='image', shape=[1, 32, 32], dtype='float32')
data2 = fluid.layers.data(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def conv_net(img, label):
pool_type='max',
act="relu",
)
conv_pool_1 = fluid.layers.batch_norm(conv_pool_1)
conv_pool_1 = paddle.static.nn.batch_norm(conv_pool_1)
conv_pool_2 = fluid.nets.simple_img_conv_pool(
input=conv_pool_1,
filter_size=5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def conv_net(img, label):
pool_type='max',
act="relu",
)
conv_pool_1 = fluid.layers.batch_norm(conv_pool_1)
conv_pool_1 = paddle.static.nn.batch_norm(conv_pool_1)
conv_pool_2 = fluid.nets.simple_img_conv_pool(
input=conv_pool_1,
filter_size=5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def conv_bn_layer(
act=None,
bias_attr=bias_attr,
)
return fluid.layers.batch_norm(input=tmp, act=act)
return paddle.static.nn.batch_norm(input=tmp, act=act)

def shortcut(input, ch_in, ch_out, stride):
if ch_in != ch_out:
Expand Down Expand Up @@ -97,7 +97,7 @@ def conv_block(input, num_filter, groups, dropouts):

drop = fluid.layers.dropout(x=conv5, dropout_prob=0.5)
fc1 = fluid.layers.fc(input=drop, size=4096, act=None)
bn = fluid.layers.batch_norm(input=fc1, act='relu')
bn = paddle.static.nn.batch_norm(input=fc1, act='relu')
drop2 = fluid.layers.dropout(x=bn, dropout_prob=0.5)
fc2 = fluid.layers.fc(input=drop2, size=4096, act=None)
return fc2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def conv_bn_layer(
act=None,
bias_attr=bias_attr,
)
return fluid.layers.batch_norm(input=tmp, act=act)
return paddle.static.nn.batch_norm(input=tmp, act=act)

def shortcut(input, ch_in, ch_out, stride):
if ch_in != ch_out:
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/fluid/contrib/tests/test_quantize_transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def conv_bn_layer(
act=None,
bias_attr=bias_attr,
)
return fluid.layers.batch_norm(input=tmp, act=act)
return paddle.static.nn.batch_norm(input=tmp, act=act)

data = fluid.layers.data(name='image', shape=[1, 32, 32], dtype='float32')
label = fluid.layers.data(name='label', shape=[1], dtype='int64')
Expand All @@ -72,7 +72,7 @@ def conv_net(img, label):
pool_stride=2,
act="relu",
)
conv_pool_1 = fluid.layers.batch_norm(conv_pool_1)
conv_pool_1 = paddle.static.nn.batch_norm(conv_pool_1)
conv_pool_2 = fluid.nets.simple_img_conv_pool(
input=conv_pool_1,
filter_size=5,
Expand Down
Loading

0 comments on commit 9733913

Please sign in to comment.