@@ -190,6 +190,19 @@ def global_step_transform(*args, **kwargs):
190
190
global_step_transform=global_step_transform
191
191
)
192
192
193
+ Another example where the State Attributes ``trainer.state.alpha`` and ``trainer.state.beta``
194
+ are also logged along with the NLL and Accuracy after each iteration:
195
+
196
+ .. code-block:: python
197
+
198
+ plx_logger.attach_output_handler(
199
+ trainer,
200
+ event_name=Events.ITERATION_COMPLETED,
201
+ tag="training",
202
+ metrics=["nll", "accuracy"],
203
+ state_attributes=["alpha", "beta"],
204
+ )
205
+
193
206
Args:
194
207
tag: common title for all produced plots. For example, "training"
195
208
metric_names: list of metric names to plot or a string "all" to plot all available
@@ -203,6 +216,7 @@ def global_step_transform(*args, **kwargs):
203
216
Default is None, global_step based on attached engine. If provided,
204
217
uses function output as global_step. To setup global step from another engine, please use
205
218
:meth:`~ignite.contrib.handlers.polyaxon_logger.global_step_from_engine`.
219
+ state_attributes: list of attributes of the ``trainer.state`` to plot.
206
220
207
221
Note:
208
222
@@ -213,6 +227,8 @@ def global_step_transform(*args, **kwargs):
213
227
def global_step_transform(engine, event_name):
214
228
return engine.state.get_event_attrib_value(event_name)
215
229
230
+ .. versionchanged:: 0.5.0
231
+ accepts an optional list of `state_attributes`
216
232
"""
217
233
218
234
def __init__ (
@@ -221,8 +237,11 @@ def __init__(
221
237
metric_names : Optional [List [str ]] = None ,
222
238
output_transform : Optional [Callable ] = None ,
223
239
global_step_transform : Optional [Callable ] = None ,
240
+ state_attributes : Optional [List [str ]] = None ,
224
241
):
225
- super (OutputHandler , self ).__init__ (tag , metric_names , output_transform , global_step_transform )
242
+ super (OutputHandler , self ).__init__ (
243
+ tag , metric_names , output_transform , global_step_transform , state_attributes
244
+ )
226
245
227
246
def __call__ (self , engine : Engine , logger : PolyaxonLogger , event_name : Union [str , Events ]) -> None :
228
247
0 commit comments