<commit_before>use self::closed01bipolar::Closed01Bipolar;
use super::ActivationFunction;

pub mod closed01bipolar;

pub struct Linear;
pub struct Gaussian;
pub struct Sigmoid;
pub struct Sine;

impl ActivationFunction for Linear {
    type Output = Closed01Bipolar<f64>;

    fn formula() -> &'static str {
        "y = max(-1.0, min(1.0, x))"
    }

    fn calculate(x: f64) -> Self::Output {
        Closed01Bipolar::new_clipped(x)
    }
}

impl ActivationFunction for Gaussian {
    type Output = Closed01Bipolar<f64>;

    fn formula() -> &'static str {
        "y = 2.0 * exp(-(x * 2.5)^2.0) - 1.0"
    }

    fn calculate(x: f64) -> Self::Output {
        Closed01Bipolar::new(2.0 * (-(x * 2.5).powi(2)).exp() - 1.0)
    }
}

impl ActivationFunction for Sigmoid {
    type Output = Closed01Bipolar<f64>;

    fn formula() -> &'static str {
        "y = 2.0 / (1.0 + exp(-4.9 * x)) - 1.0"
    }

    fn calculate(x: f64) -> Self::Output {
        Closed01Bipolar::new((2.0 / (1.0 + (-4.9 * x).exp())) - 1.0)
    }
}

impl ActivationFunction for Sine {
    type Output = Closed01Bipolar<f64>;

    fn formula() -> &'static str {
        "y = sin(2.0 * x)"
    }

    fn calculate(x: f64) -> Self::Output {
        Closed01Bipolar::new(2.0 * x.sin())
    }
}<commit_msg>Fix Sine ActivationFunction<commit_after>use self::closed01bipolar::Closed01Bipolar;
use super::ActivationFunction;

pub mod closed01bipolar;

pub struct Linear;
pub struct Gaussian;
pub struct Sigmoid;
pub struct Sine;

impl ActivationFunction for Linear {
    type Output = Closed01Bipolar<f64>;

    fn formula() -> &'static str {
        "y = max(-1.0, min(1.0, x))"
    }

    fn calculate(x: f64) -> Self::Output {
        Closed01Bipolar::new_clipped(x)
    }
}

impl ActivationFunction for Gaussian {
    type Output = Closed01Bipolar<f64>;

    fn formula() -> &'static str {
        "y = 2.0 * exp(-(x * 2.5)^2.0) - 1.0"
    }

    fn calculate(x: f64) -> Self::Output {
        Closed01Bipolar::new(2.0 * (-(x * 2.5).powi(2)).exp() - 1.0)
    }
}

impl ActivationFunction for Sigmoid {
    type Output = Closed01Bipolar<f64>;

    fn formula() -> &'static str {
        "y = 2.0 / (1.0 + exp(-4.9 * x)) - 1.0"
    }

    fn calculate(x: f64) -> Self::Output {
        Closed01Bipolar::new((2.0 / (1.0 + (-4.9 * x).exp())) - 1.0)
    }
}

impl ActivationFunction for Sine {
    type Output = Closed01Bipolar<f64>;

    fn formula() -> &'static str {
        "y = sin(2.0 * x)"
    }

    fn calculate(x: f64) -> Self::Output {
        Closed01Bipolar::new((2.0 * x).sin())
    }
}
{'fraction_non_alphanumeric': 0.1684867394695788, 'fraction_numerical': 0.06006240249609984, 'mean_word_length': 2.508891928864569, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '4695539', 'n_tokens_mistral': 1064, 'n_tokens_neox': 947, 'n_words': 220}