File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed
fluid/image_classification Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change 22import paddle .fluid as fluid
33
44
5- def inception_v4 (image , label ):
5+ def inception_v4 (img , class_dim ):
66
7- tmp = stem (input = image )
7+ tmp = stem (input = img )
88 for i in range (0 , 4 ):
99 tmp = inception_A (input = tmp , depth = i )
1010 tmp = reduction_A (input = tmp )
11-
11+ '''
1212 for i in range(0, 7):
1313 tmp = inception_B(input=tmp, depth=i)
1414 reduction_B(input=tmp)
1515
1616 for i in range(0, 3):
1717 tmp = inception_C(input=tmp, depth=i)
18-
18+ '''
1919 pool = fluid .layers .pool2d (
2020 pool_type = 'ave' , input = tmp , pool_size = 7 , pool_stride = 1 )
2121 dropout = fluid .layers .dropout (input = pool , drop_prob = 0.2 )
22- out = fluid .layers .softmax (input = dropout )
22+ fc = fluid .layers .fc (input = dropout , size = class_dim , act = 'softmax' )
23+ out = fluid .layers .softmax (input = fc )
2324 return out
2425
2526
@@ -122,15 +123,13 @@ def inception_A(input, depth):
122123 b2_conv1 = conv_bn_layer (
123124 name = 'inceptA{0}_branch2_conv1' .format (depth ),
124125 input = b2_conv0 ,
125- num_channels = 64 ,
126126 num_filters = 96 ,
127127 filter_size = 3 ,
128128 stride = 1 ,
129129 padding = 1 )
130130 b3_conv0 = conv_bn_layer (
131131 name = 'inceptA{0}_branch3_conv0' .format (depth ),
132132 input = input ,
133- num_channels = 384 ,
134133 num_filters = 64 ,
135134 filter_size = 1 ,
136135 stride = 1 ,
Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ def train_parallel_exe(args,
222222 use_nccl = True ,
223223 lr_strategy = None ,
224224 layers = 50 ):
225- class_dim = 1000
225+ class_dim = 101
226226 image_shape = [3 , 224 , 224 ]
227227
228228 image = fluid .layers .data (name = 'image' , shape = image_shape , dtype = 'float32' )
@@ -284,8 +284,15 @@ def if_exist(var):
284284
285285 fluid .io .load_vars (exe , pretrained_model , predicate = if_exist )
286286
287- train_reader = paddle .batch (reader .train (), batch_size = batch_size )
288- test_reader = paddle .batch (reader .test (), batch_size = batch_size )
287+ #train_reader = paddle.batch(reader.train(), batch_size=batch_size)
288+ #test_reader = paddle.batch(reader.test(), batch_size=batch_size)
289+ train_reader = paddle .batch (
290+ paddle .reader .shuffle (
291+ paddle .dataset .flowers .train (), buf_size = 5120 ),
292+ batch_size = args .batch_size )
293+ test_reader = paddle .batch (
294+ paddle .dataset .flowers .test (), batch_size = args .batch_size )
295+
289296 feeder = fluid .DataFeeder (place = place , feed_list = [image , label ])
290297
291298 train_exe = fluid .ParallelExecutor (use_cuda = True , loss_name = avg_cost .name )
You can’t perform that action at this time.
0 commit comments