public IReadOnlyCollection <NGram <Chord>[]> Themes(INGramWeightAssigner <Chord> assigner)
        {
            NGramGraphChainRetriever <Chord> mostProbable = new NGramGraphChainRetriever <Chord>(this.MarkovGraph);

            var chains = mostProbable.FromEachNodeRandom(assigner, this.WalkerDepth, 3);


            //KMeans<NGram<Chord>> cluster = new KMeans<NGram<Chord>>(chains.ToArray(), new LevenshteinDistance<NGram<Chord>>(), 500);
            //cluster.RunFrames(2);

            DiscreteNeuralNetworkByChord teacher = DiscreteNeuralNetworkByChord.Load(@"C:\Users\armen_000\Documents\Visual Studio 2013\Projects\Improvisation\Improvisation\bin\Debug\Learning\eminemNN.txt");

            ChordChainGeneticFunction function = new ChordChainGeneticFunction(
                teacher,
                this.MarkovGraph,
                assigner,
                ChordChainGeneticFunction.ChordRandomFunctionType.AllowRandomSelection,
                ChordChainGeneticFunction.ChordCrossFunctionType.DiscreteChoice)
            {
                RandomSelectionCoefficient = 0.3D
            };

            GeneticAlgorithm <NGram <Chord>[]> genetic = new GeneticAlgorithm <NGram <Chord>[]>(
                function,
                new GeneticSettings(0.1F, 0.05f, 5000, GeneticSettings.OrderOfEvolution.MutateCrossover),
                chains.Take(500));

            for (int i = 0; i < 3; i++)
            {
                try
                {
                    var l = genetic.SingleEvolutionaryCycle();
                }
                catch (Exception e)
                {
                    continue;
                }

                // KMeans<NGram<Chord>> chords = new KMeans<NGram<Chord>>(
                // genetic.CurrentPopulation.Select(x => x.Value).RandomValues(1000),
                // new GaussianNoiseDistance<NGram<Chord>>(new ChordHammingDistance(), 010F), 1000);

                // chords.RunFrames(3);
                // genetic.SubstitutePopulation(chords.Centers);
            }

            return(genetic.ToList().AsReadOnly());
        }
Example #2
0
        private void loadNeuralNetworkButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            DialogResult   result          = openFileDialog1.ShowDialog(); // Show the dialog.

            if (result == DialogResult.OK)                                 // Test result.
            {
                string file = openFileDialog1.FileName;
                try
                {
                    this.neuralNetwork = DiscreteNeuralNetworkByChord.Load(file);
                    this.loadNeuralNetworkTextbox.Text = FinalUIHelperMethods.FileFriendlyString(openFileDialog1.FileName);
                }

                catch (Exception ex)
                {
                    MessageBox.Show("Could Not Load NN", ex.Message);
                }
            }
        }
Example #3
0
        private void loadNeuralNetworkButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            // Test result.
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string file = openFileDialog1.FileName;

                try
                {
                    this.neuralNetwork = DiscreteNeuralNetworkByChord.Load(file);
                    this.loadNeuralNetworkTextbox.Text = Path.GetFileName(openFileDialog1.FileName);
                }

                catch (Exception ex)
                {
                    MessageBox.Show("Could Not Load Neural Network", ex.Message);
                }
            }
        }