Train() public method

public Train ( ) : void
return void
Esempio n. 1
0
        static void ANNFFNAccomp()
        {
            Databank db = new Databank("lib");
            var cat = db.Load("Classical");

            Composition inputComp = cat.Compositions[6];
            MelodySequence inputSeq = inputComp.Tracks[0].GetMainSequence() as MelodySequence;

            AccompanimentGeneratorANNFF gen = new AccompanimentGeneratorANNFF(cat, PatchNames.Acoustic_Grand);
            //gen.Initialize();
            gen.SetSequence(inputSeq);
            gen.Train();

            var outMel = gen.Generate();

            MusicPlayer player = new MusicPlayer();

            Composition comp = new Composition();
            Track t = new Track(PatchNames.Orchestral_Strings, 6);
            t.AddSequence(outMel);
            comp.Add(t);
            comp.Add(inputComp.Tracks[0]);
            player.Play(comp);
            comp.WriteToMidi("ann_ff_accomp.mid");
        }
Esempio n. 2
0
        static void TrainANNFFAccomp()
        {
            Console.WriteLine("This application trains accompaniment neural networks");
            var cats = Databank.GetCategories();

            Databank db = new Databank("lib");

            var popularInstruments = new PatchNames[]{PatchNames.Acoustic_Grand,PatchNames.String_Ensemble_1,
                PatchNames.Acoustic_Bass,PatchNames.Trumpet,PatchNames.Vibraphone,PatchNames.Electric_Grand,
                PatchNames.French_Horn,PatchNames.Flute,PatchNames.Trombone,PatchNames.Music_Box};

            foreach (var catName in cats)
            {

                Console.WriteLine("Category {0}", catName);
                var cat = db.Load(catName);

                if (cat.Compositions.Length > 3000)
                    Console.WriteLine("Skipping category {0} due to length", cat.CategoryName);

                foreach (var instr in popularInstruments)
                {
                    Console.WriteLine("Training ANN for {0} - {1}, {2} epochs", cat.ToString(), instr.ToString(), 6000);

                    try
                    {
                        AccompanimentGeneratorANNFF ann = new AccompanimentGeneratorANNFF(cat, instr);
                        ann.Epochs = 5000;
                        ann.Train();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }

                }

            }

            Console.ReadLine();
        }