No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

activations.c 723B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include "activations.h"
  5. float sigmoid(float weighted_sum)
  6. {
  7. return 1.0 / (1.0 + exp(-weighted_sum));
  8. }
  9. float sigmoid_derivative(float output)
  10. {
  11. return sigmoid(output) * (1.0 - sigmoid(output));
  12. }
  13. float tan_hyp(float weighted_sum)
  14. {
  15. return tanh(weighted_sum);
  16. }
  17. float tan_hyp_derivative(float output)
  18. {
  19. return 1.0 - (tan_hyp(output) * tan_hyp(output));
  20. }
  21. float relu(float weighted_sum)
  22. {
  23. return (weighted_sum > 0.0) ? weighted_sum : 0.0;
  24. }
  25. float relu_derivative(float output)
  26. {
  27. return (output > 0.0) ? 1.0 : 0.0;
  28. }
  29. float linear(float weighted_sum)
  30. {
  31. return weighted_sum;
  32. }
  33. float linear_derivative(float output)
  34. {
  35. return 1.0;
  36. }