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