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

Function TowerContext

tensorpack/tfutils/tower.py:232–248  ·  view source on GitHub ↗

The context for a tower function, containing metadata about the current tower. Tensorpack trainers use :class:`TowerContext` to manage tower function. Many tensorpack layers have to be called under a :class:`TowerContext`. Example: .. code-block:: python with TowerCon

(tower_name, is_training, vs_name='')

Source from the content-addressed store, hash-verified

230
231
232def TowerContext(tower_name, is_training, vs_name=''):
233 """
234 The context for a tower function, containing metadata about the current tower.
235 Tensorpack trainers use :class:`TowerContext` to manage tower function.
236 Many tensorpack layers have to be called under a :class:`TowerContext`.
237
238 Example:
239
240 .. code-block:: python
241
242 with TowerContext('', is_training=True):
243 # call a tensorpack layer or a tower function
244 """
245 if is_training:
246 return TrainTowerContext(tower_name, vs_name=vs_name)
247 else:
248 return PredictTowerContext(tower_name, vs_name=vs_name)
249
250
251class TowerFunc(object):

Callers 5

_build_gan_trainerMethod · 0.90
__init__Method · 0.90
_build_gan_trainerMethod · 0.90
__init__Method · 0.90
shufflenet.pyFile · 0.85

Calls 2

TrainTowerContextClass · 0.85
PredictTowerContextClass · 0.85

Tested by

no test coverage detected