Write code

Create a custom metric function:

Wherever you see fit, define a function that will be a custom metric.
For example:

defaccuracy(correct_count,total):# Here you can put any calculation you would like.# The function may have any parameters you need,# but it must return a single numeric value.# In this example, we demonstrate it by calculating the accuracy of the model.return(correct_count/total)*100.0

Create an experiment and pass the metrics:

Similarly to the way you passed in regular metrics to the experiment, you need to pass in the custom metric.
Add the accuracy metric to the metrics dictionary in the experiment call, so:

Now, all you need to do is call the wrapped function in your training loop,
in your validation loop, or wherever you want to.
MissingLink will monitor the result of the function whenever you call it (as long as the experiment is running, of course).

You can call the accuracy function in a number of ways:

If you call it inside the scope of a batch, then you'll get a point on a graph for every batch.

If you call it inside the scope of an epoch, then you'll get a point on a graph for every epoch.

If you call it inside the validation phase, then these points appear in the validation graph for this metric.

If you call it inside the test phase, then these points appear in the test graph for this metric.