[−][src]Function deep_learning_playground::perceptron::multi::xor_perceptron
pub fn xor_perceptron() -> Box<dyn Fn(bool, bool) -> bool>
xor_perceptron
generates the XOR function.
Let \(p\) and \(q\) are logical variables, xor_perceptron
generates the function which
satisfies the following truth table.
\(p\) | \(q\) | xor_perceptron()( \(p\), \(q\)) |
---|---|---|
\(1\) | \(1\) | \(0\) |
\(1\) | \(0\) | \(1\) |
\(0\) | \(1\) | \(1\) |
\(0\) | \(0\) | \(0\) |
e.g.
assert_eq!(true, deep_learning_playground::perceptron::multi::xor_perceptron()(true, false)); assert_eq!(false, deep_learning_playground::perceptron::multi::xor_perceptron()(true, true));