public Topology(ActivationFuncType activationFunc, int inputneurons, int outputneurons, params int[] hiddenneurons) { InputCount = inputneurons; OutputCount = outputneurons; HiddenLayers = hiddenneurons; ActivationFunc = activationFunc; }
/// <summary> /// Конструктор перцептрона /// </summary> /// <param name="funcType">Тип функции активации</param> /// <param name="layers">Массив, где каждый элемент - количество нейронов на слое</param> /// <param name="WithSoftmax">Использовать ли SoftMax</param> public BNPNet(ActivationFuncType funcType, int[] layers, bool WithSoftmax = false) { ActivationFuncType = funcType; this.WithSoftmax = WithSoftmax; SetActivationFunc(funcType); Layers = new List <Neuron[]>(layers.Length); for (int i = 0; i < layers.Length; i++) { if (i != layers.Length - 1) { Layers.Add(new Neuron[layers[i] + 1]); Layers[i][^ 1] = new Neuron {
public static double Use(ActivationFuncType type, double x) // Возвращает результат выбранной функции { switch (type) { case ActivationFuncType.Sigmoid: double result = (1 / (1 + Math.Pow(Math.E, -x))); return(result); default: throw new Exception("Функция активации использована неверно"); } }
public static double UseDX(ActivationFuncType type, double output) { switch (type) { case ActivationFuncType.Sigmoid: double result = output * (1 - output); return(result); default: throw new Exception("Производная функции активации использована неверно"); } }