Skip to content

Commit f428e82

Browse files
authored
Prediction should be a part of inference_network in new API (#10356)
1 parent 0595f23 commit f428e82

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

python/paddle/fluid/tests/book/image_classification/notest_image_classification_resnet.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,14 @@ def layer_warp(block_func, input, ch_in, ch_out, count, stride):
6464
res3 = layer_warp(basicblock, res2, 32, 64, n, 2)
6565
pool = fluid.layers.pool2d(
6666
input=res3, pool_size=8, pool_type='avg', pool_stride=1)
67-
return pool
67+
predict = fluid.layers.fc(input=pool, size=10, act='softmax')
68+
return predict
6869

6970

7071
def inference_network():
71-
classdim = 10
7272
data_shape = [3, 32, 32]
7373
images = fluid.layers.data(name='pixel', shape=data_shape, dtype='float32')
74-
net = resnet_cifar10(images, 32)
75-
predict = fluid.layers.fc(input=net, size=classdim, act='softmax')
74+
predict = resnet_cifar10(images, 32)
7675
return predict
7776

7877

python/paddle/fluid/tests/book/image_classification/notest_image_classification_vgg.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ def conv_block(input, num_filter, groups, dropouts):
4343
bn = fluid.layers.batch_norm(input=fc1, act='relu')
4444
drop2 = fluid.layers.dropout(x=bn, dropout_prob=0.5)
4545
fc2 = fluid.layers.fc(input=drop2, size=4096, act=None)
46-
return fc2
46+
predict = fluid.layers.fc(input=fc2, size=10, act='softmax')
47+
return predict
4748

4849

4950
def inference_network():
50-
classdim = 10
5151
data_shape = [3, 32, 32]
5252
images = fluid.layers.data(name='pixel', shape=data_shape, dtype='float32')
53-
net = vgg16_bn_drop(images)
54-
predict = fluid.layers.fc(input=net, size=classdim, act='softmax')
53+
predict = vgg16_bn_drop(images)
5554
return predict
5655

5756

0 commit comments

Comments
 (0)