Ejemplo n.º 1
0
        internal Training(NeuralNetwork Network, TrainingMode mode)
            : base(Network, DetermineIterationRepeatPars(Network))
        {
            Contract.Requires(Network != null);

            Mode = mode;

            if (Mode == TrainingMode.Streamed && (GCAlgo != GradientComputingAlgorithm.RTLR || GCAlgo != GradientComputingAlgorithm.None))
            {
                throw new InvalidOperationException("Only RTLR allowed for Streamed training. You have to use Recurrent NN with RTLR Algorithm in RecurrentOptions.");
            }

            if ((Network.StructuralElementFlags & NNStructuralElement.GradientInformation) != 0)
            {
                if (Network.IsRecurrent)
                {
                    GCAlgo = Network.RecurrentOptions.Algorithm == RLAlgorithm.BPTT ? GradientComputingAlgorithm.BPTT : GradientComputingAlgorithm.RTLR;
                }
                else
                {
                    GCAlgo = GradientComputingAlgorithm.BP;
                }
            }
            else
            {
                GCAlgo = GradientComputingAlgorithm.None;
            }
        }
Ejemplo n.º 2
0
        public WeightedCombiner(NetworkMatrix weights, NetworkVector biases, TrainingMode mode)
            : base(mode)
        {
            if (weights == null)
            {
                throw new ArgumentException("Attempt to create a WeightedCombiner with null weights.");
            }

            if (biases == null)
            {
                throw new ArgumentException("Attempt to create a WeightedCombiner with null biases.");
            }

            if (biases.Dimension != weights.NumberOfOutputs)
            {
                throw new ArgumentException("Dimension of biases must the the same of the outputs.");
            }

            _weights = weights.Copy();
            _biases  = biases.Copy();

            _inputs        = new NetworkVector(NumberOfInputs);
            _outputs       = new NetworkVector(NumberOfOutputs);
            _inputGradient = new NetworkVector(NumberOfInputs);
        }
Ejemplo n.º 3
0
        internal Training(NeuralNetwork network, BufferAllocator allocator, TrainingMode mode)
            : base(network, DetermineIterationRepeat(network), allocator)
        {
            Contract.Requires(network != null);
            Contract.Requires(allocator != null);

            Mode = mode;

            if (Mode == TrainingMode.Streamed && (GCAlgo != GradientComputingAlgorithm.RTLR || GCAlgo != GradientComputingAlgorithm.None))
            {
                throw new InvalidOperationException("Only RTLR allowed for Streamed training. You have to use Recurrent NN with RTLR Algorithm in RecurrentOptions.");
            }

            if ((network.StructuralElementFlags & NNStructuralElement.GradientInformation) != 0)
            {
                if (network.IsRecurrent)
                {
                    GCAlgo = network.RecurrentOptions.Algorithm == RLAlgorithm.BPTT ? GradientComputingAlgorithm.BPTT : GradientComputingAlgorithm.RTLR;
                }
                else
                {
                    GCAlgo = GradientComputingAlgorithm.BP;
                }
            }
            else
            {
                GCAlgo = GradientComputingAlgorithm.None;
            }

            if (GCAlgo == GradientComputingAlgorithm.BPTT)
            {
                savedErrorVectors = new ErrorVectorStack(network, allocator);
            }
        }
Ejemplo n.º 4
0
        internal Training(NeuralNetwork network, TrainingMode mode)
            : base(network, DetermineIterationRepeatPars(network))
        {
            Contract.Requires(network != null);

            Mode = mode;
        }
Ejemplo n.º 5
0
    public void ToggleTrainingMode(int modeIndex)
    {
        TrainingMode selectedMode = (TrainingMode)modeIndex;

        if (!RemoveTrainingMode(selectedMode))
        {
            AddTrainingMode(selectedMode);
        }
    }
Ejemplo n.º 6
0
        public Layer(double[,] weights, double[] biases, TrainingMode mode)
            : base(mode)
        {
            int numberOfOutputs = weights.GetLength(0);
            int numberOfInputs  = weights.GetLength(1);

            _combiner       = new WeightedCombiner(weights, biases);
            _neuralFunction = null;
        }
Ejemplo n.º 7
0
        public Layer(
            double[,] weights,
            double[] biases,
            ActivationFunction activationfunction,
            DerivativeFunction derivativefunction,
            TrainingMode mode)
            : this(weights, biases)
        {
            if (activationfunction != null && derivativefunction == null)
            {
                throw new ArgumentException("derivativefunction cannot be null, if activatioin is not null");
            }

            _neuralFunction = new NeuralFunction(NumberOfOutputs, activationfunction, derivativefunction);
        }
Ejemplo n.º 8
0
 public void AddTrainingMode(TrainingMode selectedMode)
 {
     selectedTrainingModes.Add(selectedMode);
 }
Ejemplo n.º 9
0
 public bool RemoveTrainingMode(TrainingMode selectedMode)
 {
     return(selectedTrainingModes.Remove(selectedMode));
 }
Ejemplo n.º 10
0
 public bool CheckForSelectedMode(TrainingMode trainingMode)
 {
     return(selectedTrainingModes?.Contains(trainingMode) ?? false);
 }
 private void MenuVMStartPracticeRequested(List <DictionaryEntry> dictionaryEntries)
 {
     _trainingMode = TrainingMode.Practice;
     _questionVM.Initialize(dictionaryEntries);
     Content = _questionVM;
 }
Ejemplo n.º 12
0
 public void OnEventHandler(TrainingMode e)
 {
     trainMode = e.Active;
 }
Ejemplo n.º 13
0
 public TrainableNetworkComponent(TrainingMode mode)
 {
     Mode = mode;
 }
Ejemplo n.º 14
0
 protected TrainableNetworkComponent()
 {
     Mode = TrainingMode.ONLINE;
 }
 private void MenuVMStartPracticeRequested(List<DictionaryEntry> dictionaryEntries)
 {
     _trainingMode = TrainingMode.Practice;
     _questionVM.Initialize(dictionaryEntries);
     Content = _questionVM;
 }
 private void MenuVMStartCompetitionRequested(List<DictionaryEntry> dictionaryEntries)
 {
     _trainingMode = TrainingMode.Competition;
     _questionVM.Initialize(dictionaryEntries);
     Content = _questionVM;
 }