Utils

struct elsa::ml::Utils

Common ml utilities

Author

David Tellenbach

struct Encoding

Common encoding routines.

Public Static Functions

template<typename data_t>
DataContainer<data_t> toOneHot(const DataContainer<data_t> &dc, index_t numClasses, index_t batchSize)

Encode a DataContainer in one-hot encoding

We expect the input-data to be shaped as ([1,] batchSize). The new one-hot encoded descriptor has shape (num_classes, batch_size)

template<typename data_t>
DataContainer<data_t> fromOneHot(const DataContainer<data_t> dc, index_t numClasses)

Decode a DataContainer that is encoded in one-hot encoding.

struct Plotting

Utilities to plot a model.

Public Types

enum RankDir

Direction for plotting the model graph.

Values:

enumerator TD

Plot model from top to bottom.

enumerator LR

Plot model from left to right.

Public Static Functions

template<typename T>
void modelToDot([[maybe_unused]] const T &model, const std::string &filename = "model.png", RankDir rankDir = RankDir::TD, int dpi = 96)

Convert a model to Graphviz’ DOT format.

Parameters
  • model: The model to plot

  • filename: The filename of the DOT file. This parameter is optional and defaults to “model.png”

  • rankDir: The direction of the plotted DOT graph. This parameter is optional and defaults to RankDir::TD.

  • dpi: The dots-per-inch encoded in the DOT file.