var trainDataset = GetIris("iris-train.txt");
var valDataset = GetIris("iris-test.txt");
var trainer = new GDTrainer<IrisDataOneHot>
{
TrainDataset = trainDataset.Shuffle(),
ValDataset = valDataset.Shuffle(),
ModelGd = new Perceptron<IrisDataOneHot>(3),
Optimizer = new Nadam(1E-2),
Loss = new CategoricalCrossentropy(),
TrainPlan = new TrainPlan {Epoch = 20, BatchSize = 10},
Metrics = new ObservableCollection<Metric>
{
new CategoricalAccuracy(),
new Metrics.Categorical.CategoricalCrossentropy()
},
Print = _testOutputHelper.WriteLine
};
await trainer.Fit();
print(trainer.ModelGd);
var Iris1 = new IrisDataOneHot
{
Label = 1,
SepalLength = 6.6,
SepalWidth = 2.9,
PetalLength = 4.6,
PetalWidth = 1.3
};
var Iris2 = new IrisDataOneHot
{
Label = 2,
SepalLength = 7.2,
SepalWidth = 3.5,
PetalLength = 6.1,
PetalWidth = 2.4
};
var pred = trainer.ModelGd.Call(Iris1);
print(pred);
pred = trainer.ModelGd.Call(Iris2);
print(pred);
-
Notifications
You must be signed in to change notification settings - Fork 0
ML with C#
License
xin-pu/ML-Sharp
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
ML with C#
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published