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='')
| 230 | |
| 231 | |
| 232 | def 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 | |
| 251 | class TowerFunc(object): |
no test coverage detected