#include "Activation.h" float Activation::HeavisideStep(float inputValue, float bias) { return (inputValue + bias > 0) ? 1.0F : 0.0F; } float Activation::Tanh(float inputValue) { return (exp(inputValue) - exp(-inputValue)) / (exp(inputValue) + exp(-inputValue)); } float Activation::Sigmoid(float inputValue) { return 1 / (1 + expf(-inputValue)); } float Activation::Linear(float inputValue, float minValue, float range) { if (inputValue > minValue + range) return 0; if (inputValue < minValue) return 1; float f = (inputValue - minValue) * (1 / range); // normalize to 1..0 float influence = 1 - f; // invert return influence; } float Activation::Quadratic(float inputValue, float minValue, float range) { if (inputValue > minValue + range) return 0; if (inputValue < minValue) return 1; float f = (inputValue - minValue) * (1 / range); // normalize to 1..0 float influence = 1 - (f * f); // quadratic & invert return influence; } float Activation::ParticleLife(float minValue, float maxValue, float attraction, float inputValue) { if (inputValue < minValue) return inputValue / minValue - 1; if (inputValue < maxValue) return attraction * (1 - fabs(2 * inputValue - minValue - maxValue) / (maxValue - minValue)); return 0; }