Advertisement
Guest User

xssss

a guest
Feb 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9. abstract class Neuron
  10. {
  11. private static Random random = new Random();
  12. protected List<double> weights;
  13. public List<double> Inputs { get; set; }
  14. public Func<double, double> ActivationFunction { get; set; }
  15. public abstract void Train(double eps, List<List<double>> trainSet);
  16. protected void InitWeights(double startRange, double endRange)
  17. {
  18. for (int i = 0; i < weights.Count; i++)
  19. {
  20. weights[i] =
  21. random.NextDouble() * (endRange - startRange) + startRange;
  22. }
  23. }
  24. public double Output { get { return CalculatedOutput(); } }
  25. private double CalculatedOutput()
  26. {
  27. return Inputs.Zip(weights, (x, weights) => x * weights).Sum();
  28. }
  29. }
  30. class Program
  31. {
  32. static void Main(string[] args)
  33. {
  34.  
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement