MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / get_config

Function get_config

examples/ImageNetModels/shufflenet.py:189–222  ·  view source on GitHub ↗
(model, nr_tower)

Source from the content-addressed store, hash-verified

187
188
189def get_config(model, nr_tower):
190 batch = TOTAL_BATCH_SIZE // nr_tower
191
192 logger.info("Running on {} towers. Batch size per tower: {}".format(nr_tower, batch))
193 dataset_train = get_data('train', batch)
194 dataset_val = get_data('val', batch)
195
196 step_size = 1280000 // TOTAL_BATCH_SIZE
197 max_iter = 3 * 10**5
198 max_epoch = (max_iter // step_size) + 1
199 callbacks = [
200 ModelSaver(),
201 ScheduledHyperParamSetter('learning_rate',
202 [(0, 0.5), (max_iter, 0)],
203 interp='linear', step_based=True),
204 EstimatedTimeLeft()
205 ]
206 infs = [ClassificationError('wrong-top1', 'val-error-top1'),
207 ClassificationError('wrong-top5', 'val-error-top5')]
208 if nr_tower == 1:
209 # single-GPU inference with queue prefetch
210 callbacks.append(InferenceRunner(QueueInput(dataset_val), infs))
211 else:
212 # multi-GPU inference (with mandatory queue prefetch)
213 callbacks.append(DataParallelInferenceRunner(
214 dataset_val, infs, list(range(nr_tower))))
215
216 return TrainConfig(
217 model=model,
218 dataflow=dataset_train,
219 callbacks=callbacks,
220 steps_per_epoch=step_size,
221 max_epoch=max_epoch,
222 )
223
224
225if __name__ == '__main__':

Callers 1

shufflenet.pyFile · 0.70

Calls 11

ModelSaverClass · 0.85
EstimatedTimeLeftClass · 0.85
ClassificationErrorClass · 0.85
InferenceRunnerClass · 0.85
QueueInputClass · 0.85
TrainConfigClass · 0.85
formatMethod · 0.80
appendMethod · 0.80
get_dataFunction · 0.70

Tested by

no test coverage detected