<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function

import tensorflow as tf

# Functions for changing which quantities we monitor while training a model

def QuantitiesToMonitor(predictions, labels, param):
    """
    For now this is effectively just a placeholder to makes sure NiftyNet's default behaviour stays the same.
    Soon we will have KL divergence, log likelihood, discriminatory accuracy & other model-specific training summaries
    that we can switch on and off when defining a model.
    :param predictions: outputs of the model.
    :param labels: ground truth.
    :param param: the imported configuration file.
    :return: a list of quantities to monitor during training in 'quantities_to_monitor', with their human-readable
    names in 'names_of_quantities'
    """
    quantities_to_monitor = []
    names_of_quantities = []

    if ('miss_rate' in param) and (not param['miss_rate']):
        pass
    else:
        quantities_to_monitor.append(tf.reduce_mean(tf.cast(
            tf.not_equal(tf.argmax(predictions, -1), labels[..., 0]),
            dtype=tf.float32)))
        names_of_quantities.append('miss rate')

    return [quantities_to_monitor, names_of_quantities]
<commit_msg>no message<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function

import tensorflow as tf

def QuantitiesToMonitor(predictions, labels, dictionary):
    """
    Change which quantities to calculate and monitor while training a model
    For now this is effectively just a placeholder to makes sure NiftyNet's default behaviour stays the same.
    Soon we will have a KL divergence, log likelihood, discriminatory accuracy & other model-specific quantities.
    :dictionary predictions: outputs of the model.
    :dictionary labels: ground truth.
    :dictionary dictionary: the dictionary of quantities to monitor
    :return: the list of quantities to calculate and display during training
    """
    quantities_to_monitor = []
    names_of_quantities = []

    if ('miss_rate' in dictionary) and (not dictionary['miss_rate']):
        pass
    else:
        quantities_to_monitor.append(tf.reduce_mean(tf.cast(
            tf.not_equal(tf.argmax(predictions, -1), labels[..., 0]),
            dtype=tf.float32)))
        names_of_quantities.append('miss rate')

    return [quantities_to_monitor, names_of_quantities]

{'fraction_non_alphanumeric': 0.08115942028985507, 'fraction_numerical': 0.004140786749482402, 'mean_word_length': 3.6551059730250484, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6788165', 'n_tokens_mistral': 655, 'n_tokens_neox': 637, 'n_words': 234}