private static void SampleWdbc() { SigmaEnvironment sigma = SigmaEnvironment.Create("wdbc"); IDataset dataset = Defaults.Datasets.Wdbc(); ITrainer trainer = sigma.CreateGhostTrainer("wdbc-trainer"); trainer.Network.Architecture = InputLayer.Construct(30) + FullyConnectedLayer.Construct(42) + FullyConnectedLayer.Construct(24) + FullyConnectedLayer.Construct(1) + OutputLayer.Construct(1) + SquaredDifferenceCostLayer.Construct(); trainer.TrainingDataIterator = new MinibatchIterator(72, dataset); trainer.AddNamedDataIterator("validation", new UndividedIterator(dataset)); trainer.Optimiser = new GradientDescentOptimiser(learningRate: 0.005); trainer.AddInitialiser("*.*", new GaussianInitialiser(standardDeviation: 0.1)); trainer.AddLocalHook(new AccumulatedValueReporter("optimiser.cost_total", TimeStep.Every(1, TimeScale.Epoch))); trainer.AddHook(new UniClassificationAccuracyReporter("validation", 0.5, TimeStep.Every(1, TimeScale.Epoch))); sigma.AddTrainer(trainer); sigma.AddMonitor(new HttpMonitor("http://+:8080/sigma/")); sigma.PrepareAndRun(); }
private static void SampleParkinsons() { SigmaEnvironment sigma = SigmaEnvironment.Create("parkinsons"); IDataset dataset = Defaults.Datasets.Parkinsons(); ITrainer trainer = sigma.CreateGhostTrainer("parkinsons-trainer"); trainer.Network.Architecture = InputLayer.Construct(22) + FullyConnectedLayer.Construct(140) + FullyConnectedLayer.Construct(20) + FullyConnectedLayer.Construct(1) + OutputLayer.Construct(1) + SquaredDifferenceCostLayer.Construct(); trainer.TrainingDataIterator = new MinibatchIterator(10, dataset); trainer.AddNamedDataIterator("validation", new UndividedIterator(dataset)); trainer.Optimiser = new AdagradOptimiser(baseLearningRate: 0.01); trainer.AddInitialiser("*.*", new GaussianInitialiser(standardDeviation: 0.1)); trainer.AddLocalHook(new AccumulatedValueReporter("optimiser.cost_total", TimeStep.Every(1, TimeScale.Epoch))); trainer.AddHook(new UniClassificationAccuracyReporter("validation", 0.5, TimeStep.Every(1, TimeScale.Epoch))); sigma.AddTrainer(trainer); sigma.PrepareAndRun(); }
private static void SampleIris() { SigmaEnvironment sigma = SigmaEnvironment.Create("iris"); sigma.SetRandomSeed(0); sigma.Prepare(); IDataset dataset = Defaults.Datasets.Iris(); ITrainer trainer = sigma.CreateGhostTrainer("iris-trainer"); trainer.Network.Architecture = InputLayer.Construct(4) + FullyConnectedLayer.Construct(12) + FullyConnectedLayer.Construct(3) + OutputLayer.Construct(3) + SquaredDifferenceCostLayer.Construct(); //trainer.Network = Serialisation.ReadBinaryFileIfExists("iris.sgnet", trainer.Network); trainer.TrainingDataIterator = new MinibatchIterator(50, dataset); trainer.AddNamedDataIterator("validation", new UndividedIterator(dataset)); trainer.Optimiser = new GradientDescentOptimiser(learningRate: 0.06); trainer.Operator = new CudaSinglethreadedOperator(); trainer.AddInitialiser("*.*", new GaussianInitialiser(standardDeviation: 0.1)); //trainer.AddGlobalHook(new StopTrainingHook(atEpoch: 100)); //trainer.AddLocalHook(new EarlyStopperHook("optimiser.cost_total", 20, target: ExtremaTarget.Min)); trainer.AddLocalHook(new AccumulatedValueReporter("optimiser.cost_total", TimeStep.Every(1, TimeScale.Epoch), reportEpochIteration: true)); //.On(new ExtremaCriteria("optimiser.cost_total", ExtremaTarget.Min))); //trainer.AddLocalHook(new DiskSaviorHook<INetwork>("network.self", Namers.Dynamic("iris_epoch{0}.sgnet", "epoch"), verbose: true) // .On(new ExtremaCriteria("optimiser.cost_total", ExtremaTarget.Min))); trainer.AddHook(new MultiClassificationAccuracyReporter("validation", TimeStep.Every(1, TimeScale.Epoch), tops: 1)); trainer.AddHook(new StopTrainingHook(new ThresholdCriteria("shared.classification_accuracy_top1", ComparisonTarget.GreaterThanEquals, 0.98))); trainer.AddLocalHook(new RunningTimeReporter(TimeStep.Every(599, TimeScale.Iteration), 128)); trainer.AddLocalHook(new RunningTimeReporter(TimeStep.Every(1, TimeScale.Epoch), 4)); //Serialisation.WriteBinaryFile(trainer, "trainer.sgtrainer"); //trainer = Serialisation.ReadBinaryFile<ITrainer>("trainer.sgtrainer"); sigma.AddTrainer(trainer); sigma.AddMonitor(new HttpMonitor("http://+:8080/sigma/")); sigma.PrepareAndRun(); }