Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- abstract class Neuron
- {
- private static Random random = new Random();
- protected List<double> weights;
- public List<double> Inputs { get; set; }
- public Func<double, double> ActivationFunction { get; set; }
- public abstract void Train(double eps, List<List<double>> trainSet);
- protected void InitWeights(double startRange, double endRange)
- {
- for (int i = 0; i < weights.Count; i++)
- {
- weights[i] =
- random.NextDouble() * (endRange - startRange) + startRange;
- }
- }
- public double Output { get { return CalculatedOutput(); } }
- private double CalculatedOutput()
- {
- return Inputs.Zip(weights, (x, weights) => x * weights).Sum();
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement