44 line
No EOL
723 B
C
44 line
No EOL
723 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <math.h>
|
|
#include "activations.h"
|
|
|
|
float sigmoid(float weighted_sum)
|
|
{
|
|
return 1.0 / (1.0 + exp(-weighted_sum));
|
|
}
|
|
|
|
float sigmoid_derivative(float output)
|
|
{
|
|
return sigmoid(output) * (1.0 - sigmoid(output));
|
|
}
|
|
|
|
float tan_hyp(float weighted_sum)
|
|
{
|
|
return tanh(weighted_sum);
|
|
}
|
|
|
|
float tan_hyp_derivative(float output)
|
|
{
|
|
return 1.0 - (tan_hyp(output) * tan_hyp(output));
|
|
}
|
|
|
|
float relu(float weighted_sum)
|
|
{
|
|
return (weighted_sum > 0.0) ? weighted_sum : 0.0;
|
|
}
|
|
|
|
float relu_derivative(float output)
|
|
{
|
|
return (output > 0.0) ? 1.0 : 0.0;
|
|
}
|
|
|
|
float linear(float weighted_sum)
|
|
{
|
|
return weighted_sum;
|
|
}
|
|
|
|
float linear_derivative(float output)
|
|
{
|
|
return 1.0;
|
|
} |