Skip to content

Commit adfdbfd

Browse files
committed
Fix comments.
test=develop
1 parent cf83cbf commit adfdbfd

File tree

3 files changed

+51
-52
lines changed

3 files changed

+51
-52
lines changed

python/paddle/fluid/contrib/slim/nas/light_nas_strategy.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,20 @@ def _constrain_func(self, tokens, context=None):
136136
return False
137137

138138
def on_epoch_begin(self, context):
139-
_logger.info("light nas strategy on_epoch_begin")
140139
if context.epoch_id >= self.start_epoch and context.epoch_id <= self.end_epoch and (
141140
self._retrain_epoch == 0 or
142141
(context.epoch_id - self.start_epoch) % self._retrain_epoch == 0):
143-
_logger.info("Construct new program...")
142+
_logger.info("light nas strategy on_epoch_begin")
144143
for _ in range(self._max_try_times):
145144
startup_p, train_p, test_p, _, _, train_reader, test_reader = context.search_space.create_net(
146145
self._current_tokens)
146+
_logger.info("try [{}]".format(self._current_tokens))
147147
context.eval_graph.program = test_p
148148
flops = context.eval_graph.flops()
149149
if flops <= self._max_flops:
150150
break
151151
else:
152152
self._current_tokens = self._search_agent.next_tokens()
153-
_logger.info("try [{}]".format(self._current_tokens))
154153

155154
context.train_reader = train_reader
156155
context.eval_reader = test_reader

python/paddle/fluid/contrib/slim/prune/auto_prune_strategy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(self,
6666

6767
def on_compression_begin(self, context):
6868
"""
69-
Prepare some information for searching stategy.
69+
Prepare some information for searching strategy.
7070
step 1: Find all the parameters to be pruned.
7171
step 2: Get initial tokens and setup controller.
7272
"""

python/paddle/fluid/contrib/slim/tests/light_nas/light_nasnet.py

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ def net(self, input, bottleneck_params_list=None, class_dim=1000,
9090
i += 1
9191
input = self.invresi_blocks(
9292
input=input,
93-
in_c=in_c,
94-
t=t,
95-
c=int(c * scale),
96-
n=n,
97-
s=s,
98-
k=k,
99-
ifshortcut=ifshortcut,
100-
ifse=ifse,
93+
in_channel=in_c,
94+
expansion=t,
95+
out_channel=int(c * scale),
96+
num_layers=n,
97+
stride=s,
98+
filter_size=k,
99+
shortcut=ifshortcut,
100+
squeeze=ifse,
101101
name='conv' + str(i))
102102
in_c = int(c * scale)
103103
#last_conv
@@ -230,15 +230,15 @@ def inverted_residual_unit(self,
230230
name=None):
231231
"""Build inverted residual unit.
232232
Args:
233-
input: Variable, input.
234-
num_in_filter: int, number of in filters.
235-
num_filters: int, number of filters.
236-
ifshortcut: bool, whether using shortcut.
237-
stride: int, stride.
238-
filter_size: int, filter size.
239-
padding: int, padding.
240-
expansion_factor: float, expansion factor.
241-
name: str, name.
233+
input(Variable): Theinput.
234+
num_in_filter(int): The number of input filters.
235+
num_filters(int): The number of filters.
236+
ifshortcut(bool): Whether to use shortcut.
237+
stride(int): The stride.
238+
filter_size(int): The filter size.
239+
padding(int): The padding.
240+
expansion_factor(float): Expansion factor.
241+
name(str): The name.
242242
Returns:
243243
Variable, layers output.
244244
"""
@@ -287,53 +287,53 @@ def inverted_residual_unit(self,
287287

288288
def invresi_blocks(self,
289289
input,
290-
in_c,
291-
t,
292-
c,
293-
n,
294-
s,
295-
k,
296-
ifshortcut,
297-
ifse,
290+
in_channel,
291+
expansion,
292+
out_channel,
293+
num_layers,
294+
stride,
295+
filter_size,
296+
shortcut,
297+
squeeze,
298298
name=None):
299299
"""Build inverted residual blocks.
300300
Args:
301-
input: Variable, input.
302-
in_c: int, number of in filters.
303-
t: float, expansion factor.
304-
c: int, number of filters.
305-
n: int, number of layers.
306-
s: int, stride.
307-
k: int, filter size.
308-
ifshortcut: bool, if adding shortcut layers or not.
309-
ifse: bool, if adding squeeze excitation layers or not.
310-
name: str, name.
301+
input(Variable): The input feture map.
302+
in_channel(int): The number of input channel.
303+
expansion(float): Expansion factor.
304+
out_channel(int): The number of output channel.
305+
num_layers(int): The number of layers.
306+
stride(int): The stride.
307+
filter_size(int): The size of filter.
308+
shortcut(bool): Whether to add shortcut layers.
309+
squeeze(bool): Whether to add squeeze excitation layers.
310+
name(str): The name.
311311
Returns:
312312
Variable, layers output.
313313
"""
314314
first_block = self.inverted_residual_unit(
315315
input=input,
316-
num_in_filter=in_c,
317-
num_filters=c,
316+
num_in_filter=in_channel,
317+
num_filters=out_channel,
318318
ifshortcut=False,
319-
ifse=ifse,
320-
stride=s,
321-
filter_size=k,
322-
expansion_factor=t,
319+
ifse=squeeze,
320+
stride=stride,
321+
filter_size=filter_size,
322+
expansion_factor=expansion,
323323
name=name + '_1')
324324

325325
last_residual_block = first_block
326-
last_c = c
326+
last_c = out_channel
327327

328-
for i in range(1, n):
328+
for i in range(1, num_layers):
329329
last_residual_block = self.inverted_residual_unit(
330330
input=last_residual_block,
331331
num_in_filter=last_c,
332-
num_filters=c,
333-
ifshortcut=ifshortcut,
334-
ifse=ifse,
332+
num_filters=out_channel,
333+
ifshortcut=shortcut,
334+
ifse=squeeze,
335335
stride=1,
336-
filter_size=k,
337-
expansion_factor=t,
336+
filter_size=filter_size,
337+
expansion_factor=expansion,
338338
name=name + '_' + str(i + 1))
339339
return last_residual_block

0 commit comments

Comments
 (0)