<commit_before>package com.clutteredcode.ann.activation;

/**
 * @author <EMAIL>
 */
public enum ActivationType {
    LINEAR,
    SIGMOID,
    TAN_H;

    /**
     * Returns the {@link com.clutteredcode.ann.activation.ActivationFunction} associated with this {@code ActivationType}.
     *
     * @return the {@link com.clutteredcode.ann.activation.ActivationFunction}.
     */
    public ActivationFunction getFunction() {
        if (this.equals(TAN_H))
            return (final double input) -> Math.tanh(input);

        if (this.equals(SIGMOID))
            return (final double input) -> 1 / (1 + Math.exp(-input));

        // Default: LINEAR
        return (final double input) -> input;
    }
}<commit_msg>Use singleton ActivationFunction object in ActivationType<commit_after>package com.clutteredcode.ann.activation;

/**
 * @author <EMAIL>
 */
public enum ActivationType {
    LINEAR,
    SIGMOID,
    TAN_H;

    // Singleton lambda ActivationFunction objects
    private static final ActivationFunction LINEAR_FUNC  = (final double input) -> input;
    private static final ActivationFunction SIGMOID_FUNC = (final double input) -> 1 / (1 + Math.exp(-input));
    private static final ActivationFunction TAN_H_FUNC   = (final double input) -> Math.tanh(input);

    /**
     * Returns the {@link com.clutteredcode.ann.activation.ActivationFunction} associated with this {@code ActivationType}.
     *
     * @return The {@link com.clutteredcode.ann.activation.ActivationFunction}.
     */
    public ActivationFunction getFunction() {
        if (this == TAN_H)
            return TAN_H_FUNC;

        if (this == SIGMOID)
            return SIGMOID_FUNC;

        return LINEAR_FUNC;
    }
}
{'fraction_non_alphanumeric': 0.10954891622729936, 'fraction_numerical': 0.0023432923257176333, 'mean_word_length': 2.855530474040632, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2015174', 'n_tokens_mistral': 522, 'n_tokens_neox': 478, 'n_words': 125}