未验证 提交 40cc0b44 编写于 作者: W wangguanzhong 提交者: GitHub

update example (#1483)

上级 0b57f766
...@@ -33,7 +33,7 @@ anchor_generator ...@@ -33,7 +33,7 @@ anchor_generator
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
conv1 = fluid.layers.data(name='conv1', shape=[48, 16, 16], dtype='float32') conv1 = fluid.data(name='conv1', shape=[None, 48, 16, 16], dtype='float32')
anchor, var = fluid.layers.anchor_generator( anchor, var = fluid.layers.anchor_generator(
input=conv1, input=conv1,
anchor_sizes=[64, 128, 256, 512], anchor_sizes=[64, 128, 256, 512],
......
...@@ -34,7 +34,7 @@ bipartite_match ...@@ -34,7 +34,7 @@ bipartite_match
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
x = fluid.layers.data(name='x', shape=[4], dtype='float32') x = fluid.data(name='x', shape=[None, 4], dtype='float32')
y = fluid.layers.data(name='y', shape=[4], dtype='float32') y = fluid.data(name='y', shape=[None, 4], dtype='float32')
iou = fluid.layers.iou_similarity(x=x, y=y) iou = fluid.layers.iou_similarity(x=x, y=y)
matched_indices, matched_dist = fluid.layers.bipartite_match(iou) matched_indices, matched_dist = fluid.layers.bipartite_match(iou)
...@@ -37,8 +37,8 @@ box_clip ...@@ -37,8 +37,8 @@ box_clip
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
boxes = fluid.layers.data( boxes = fluid.data(
name='boxes', shape=[8, 4], dtype='float32', lod_level=1) name='boxes', shape=[None, 8, 4], dtype='float32', lod_level=1)
im_info = fluid.layers.data(name='im_info', shape=[3]) im_info = fluid.data(name='im_info', shape=[None, 3])
out = fluid.layers.box_clip( out = fluid.layers.box_clip(
input=boxes, im_info=im_info) input=boxes, im_info=im_info)
...@@ -65,27 +65,23 @@ Bounding Box Coder ...@@ -65,27 +65,23 @@ Bounding Box Coder
import paddle.fluid as fluid import paddle.fluid as fluid
# For encode # For encode
prior_box_encode = fluid.layers.data(name='prior_box_encode', prior_box_encode = fluid.data(name='prior_box_encode',
shape=[512, 4], shape=[512, 4],
dtype='float32', dtype='float32')
append_batch_size=False) target_box_encode = fluid.data(name='target_box_encode',
target_box_encode = fluid.layers.data(name='target_box_encode',
shape=[81,4], shape=[81,4],
dtype='float32', dtype='float32')
append_batch_size=False)
output_encode = fluid.layers.box_coder(prior_box=prior_box_encode, output_encode = fluid.layers.box_coder(prior_box=prior_box_encode,
prior_box_var=[0.1,0.1,0.2,0.2], prior_box_var=[0.1,0.1,0.2,0.2],
target_box=target_box_encode, target_box=target_box_encode,
code_type="encode_center_size") code_type="encode_center_size")
# For decode # For decode
prior_box_decode = fluid.layers.data(name='prior_box_decode', prior_box_decode = fluid.data(name='prior_box_decode',
shape=[512, 4], shape=[512, 4],
dtype='float32', dtype='float32')
append_batch_size=False) target_box_decode = fluid.data(name='target_box_decode',
target_box_decode = fluid.layers.data(name='target_box_decode',
shape=[512,81,4], shape=[512,81,4],
dtype='float32', dtype='float32')
append_batch_size=False)
output_decode = fluid.layers.box_coder(prior_box=prior_box_decode, output_decode = fluid.layers.box_coder(prior_box=prior_box_decode,
prior_box_var=[0.1,0.1,0.2,0.2], prior_box_var=[0.1,0.1,0.2,0.2],
target_box=target_box_decode, target_box=target_box_decode,
......
...@@ -49,14 +49,14 @@ box decode过程得出decode_box,然后分配方案如下所述: ...@@ -49,14 +49,14 @@ box decode过程得出decode_box,然后分配方案如下所述:
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
pb = fluid.layers.data( pb = fluid.data(
name='prior_box', shape=[4], dtype='float32') name='prior_box', shape=[None, 4], dtype='float32')
pbv = fluid.layers.data( pbv = fluid.data(
name='prior_box_var', shape=[4], dtype='float32', append_batch_size=False)) name='prior_box_var', shape=[4], dtype='float32')
loc = fluid.layers.data( loc = fluid.data(
name='target_box', shape=[4*81], dtype='float32') name='target_box', shape=[None, 4*81], dtype='float32')
scores = fluid.layers.data( scores = fluid.data(
name='scores', shape=[81], dtype='float32') name='scores', shape=[None, 81], dtype='float32')
decoded_box, output_assign_box = fluid.layers.box_decoder_and_assign( decoded_box, output_assign_box = fluid.layers.box_decoder_and_assign(
pb, pbv, loc, scores, 4.135) pb, pbv, loc, scores, 4.135)
...@@ -29,8 +29,8 @@ ClipByNorm算子 ...@@ -29,8 +29,8 @@ ClipByNorm算子
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
input = fluid.layers.data( input = fluid.data(
name='data', shape=[1], dtype='float32') name='data', shape=[None, 1], dtype='float32')
reward = fluid.layers.clip_by_norm(x=input, max_norm=1.0) reward = fluid.layers.clip_by_norm(x=input, max_norm=1.0)
......
...@@ -35,11 +35,11 @@ collect_fpn_proposals ...@@ -35,11 +35,11 @@ collect_fpn_proposals
multi_rois = [] multi_rois = []
multi_scores = [] multi_scores = []
for i in range(4): for i in range(4):
multi_rois.append(fluid.layers.data( multi_rois.append(fluid.data(
name='roi_'+str(i), shape=[4], dtype='float32', lod_level=1)) name='roi_'+str(i), shape=[None, 4], dtype='float32', lod_level=1))
for i in range(4): for i in range(4):
multi_scores.append(fluid.layers.data( multi_scores.append(fluid.data(
name='score_'+str(i), shape=[1], dtype='float32', lod_level=1)) name='score_'+str(i), shape=[None, 1], dtype='float32', lod_level=1))
fpn_rois = fluid.layers.collect_fpn_proposals( fpn_rois = fluid.layers.collect_fpn_proposals(
multi_rois=multi_rois, multi_rois=multi_rois,
......
...@@ -36,8 +36,8 @@ distribute_fpn_proposals ...@@ -36,8 +36,8 @@ distribute_fpn_proposals
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
fpn_rois = fluid.layers.data( fpn_rois = fluid.data(
name='data', shape=[4], dtype='float32', lod_level=1) name='data', shape=[None, 4], dtype='float32', lod_level=1)
multi_rois, restore_ind = fluid.layers.distribute_fpn_proposals( multi_rois, restore_ind = fluid.layers.distribute_fpn_proposals(
fpn_rois=fpn_rois, fpn_rois=fpn_rois,
min_level=2, min_level=2,
......
...@@ -38,8 +38,8 @@ maxout ...@@ -38,8 +38,8 @@ maxout
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
input = fluid.layers.data( input = fluid.data(
name='data', name='data',
shape=[256, 32, 32], shape=[None, 256, 32, 32],
dtype='float32') dtype='float32')
out = fluid.layers.maxout(input, groups=2) out = fluid.layers.maxout(input, groups=2)
...@@ -38,7 +38,7 @@ prelu ...@@ -38,7 +38,7 @@ prelu
import paddle.fluid as fluid import paddle.fluid as fluid
from paddle.fluid.param_attr import ParamAttr from paddle.fluid.param_attr import ParamAttr
x = fluid.layers.data(name="x", shape=[5,10,10], dtype="float32") x = fluid.data(name="x", shape=[None,5,10,10], dtype="float32")
mode = 'channel' mode = 'channel'
output = fluid.layers.prelu( output = fluid.layers.prelu(
x,mode,param_attr=ParamAttr(name='alpha')) x,mode,param_attr=ParamAttr(name='alpha'))
......
...@@ -35,10 +35,10 @@ Region of Interests align(直译:有意义、有价值选区对齐) 用于实 ...@@ -35,10 +35,10 @@ Region of Interests align(直译:有意义、有价值选区对齐) 用于实
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
x = fluid.layers.data( x = fluid.data(
name='data', shape=[256, 32, 32], dtype='float32') name='data', shape=[None, 256, 32, 32], dtype='float32')
rois = fluid.layers.data( rois = fluid.data(
name='rois', shape=[4], dtype='float32') name='rois', shape=[None, 4], dtype='float32')
align_out = fluid.layers.roi_align(input=x, align_out = fluid.layers.roi_align(input=x,
rois=rois, rois=rois,
pooled_height=7, pooled_height=7,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册