TensorBoardLogs

class lib.gui.analysis.event_reader.TensorBoardLogs(logs_folder: str, is_training: bool)

Bases: object

Parse data from TensorBoard logs.

Process the input logs folder and stores the individual filenames per session.

Caches timestamp and loss data on request and returns this data from the cache.

Parameters:
  • logs_folder (str) – The folder that contains the Tensorboard log files

  • is_training (bool) – True if the events are being read whilst Faceswap is training otherwise False

Attributes Summary

session_ids

Sorted list of integers of available session ids.

Methods Summary

get_loss([session_id])

Read the loss from the TensorBoard event logs

get_timestamps([session_id])

Read the timestamps from the TensorBoard logs.

set_training(is_training)

Set the internal training flag to the given is_training value.

Attributes Documentation

session_ids

Sorted list of integers of available session ids.

Methods Documentation

get_loss(session_id: int | None = None) dict[int, dict[str, ndarray]]

Read the loss from the TensorBoard event logs

Parameters:

session_id (int | None) – The Session ID to return the loss for. Set to None to return all session losses. Default None

Returns:

  • The session id(s) as key, with a further dictionary as value containing the loss name and

  • list of loss values for each step

Return type:

dict[int, dict[str, ndarray]]

get_timestamps(session_id: int | None = None) dict[int, ndarray]

Read the timestamps from the TensorBoard logs.

As loss timestamps are slightly different for each loss, we collect the timestamp from the batch_loss key.

Parameters:

session_id (int | None) – The Session ID to return the timestamps for. Set to None to return all session timestamps. Default None

Return type:

The session id(s) as key with list of timestamps per step as value

set_training(is_training: bool) bool

Set the internal training flag to the given is_training value.

If a new training session is being instigated, refresh the log filenames

Parameters:

is_training (bool) – True to indicate that the logs to be read are from the currently training session otherwise False

Returns:

  • True if the session that is starting training belongs to the session already loaded

  • otherwise False

Return type:

bool

get_loss(session_id: int | None = None) dict[int, dict[str, ndarray]]

Read the loss from the TensorBoard event logs

Parameters:

session_id (int | None) – The Session ID to return the loss for. Set to None to return all session losses. Default None

Returns:

  • The session id(s) as key, with a further dictionary as value containing the loss name and

  • list of loss values for each step

Return type:

dict[int, dict[str, ndarray]]

get_timestamps(session_id: int | None = None) dict[int, ndarray]

Read the timestamps from the TensorBoard logs.

As loss timestamps are slightly different for each loss, we collect the timestamp from the batch_loss key.

Parameters:

session_id (int | None) – The Session ID to return the timestamps for. Set to None to return all session timestamps. Default None

Return type:

The session id(s) as key with list of timestamps per step as value

property session_ids: list[int]

Sorted list of integers of available session ids.

set_training(is_training: bool) bool

Set the internal training flag to the given is_training value.

If a new training session is being instigated, refresh the log filenames

Parameters:

is_training (bool) – True to indicate that the logs to be read are from the currently training session otherwise False

Returns:

  • True if the session that is starting training belongs to the session already loaded

  • otherwise False

Return type:

bool