zea.models.utils¶

Utilities for models

Functions

onnx2tf_saved_model_kwargs()

Arguments needed to still get a SavedModel out of onnx2tf.convert().

Classes

LossTrackerWrapper(prefix)

A wrapper for Keras Mean metrics to track multiple loss values.

class zea.models.utils.LossTrackerWrapper(prefix)[source]¶

Bases: object

A wrapper for Keras Mean metrics to track multiple loss values.

Initialize the loss tracker wrapper.

Parameters:

prefix (str) – Prefix to use for the loss name. For example “n_loss” or “i_loss”.

reset_state()[source]¶

Reset all the internal trackers.

result()[source]¶

Return a dictionary with the current average results.

update_state(loss_value)[source]¶

Update the tracker(s) with a loss value.

If loss_value is a dict, then for each key a separate tracker is created (if not already created) and updated. The tracker’s name will be <prefix>_<key>. If loss_value is not a dict, then a default tracker with name <prefix> is updated.

Parameters:

loss_value – A tensor or a dictionary mapping field names to tensors.

zea.models.utils.onnx2tf_saved_model_kwargs()[source]¶

Arguments needed to still get a SavedModel out of onnx2tf.convert().

onnx2tf 2.6 made flatbuffer_direct the default backend, which emits TFLite only: the call succeeds but writes no SavedModel, which is what the presets ship. Older versions do not have the option, so it is only passed when understood.