public static async Task MultiThreadedLearning() { var example = new MyExample { Income = 40, Age = 25 }; var label = new SimpleLabel { Label = 1 }; var settings = new VowpalWabbitSettings { ParallelOptions = new ParallelOptions { MaxDegreeOfParallelism = 16 }, ExampleCountPerRun = 2000, ExampleDistribution = VowpalWabbitExampleDistribution.RoundRobin }; using (var vw = new VowpalWabbitThreadedLearning(settings)) { using (var vwManaged = vw.Create<MyExample>()) { var prediction = await vwManaged.Learn(example, label, VowpalWabbitPredictionType.Scalar); } var saveModelTask = vw.SaveModel("m1.model"); await vw.Complete(); await saveModelTask; } }
public static async Task MultiThreadedLearning() { var example = new MyExample { Income = 40, Age = 25 }; var label = new SimpleLabel { Label = 1 }; var settings = new VowpalWabbitSettings { ParallelOptions = new ParallelOptions { MaxDegreeOfParallelism = 16 }, ExampleCountPerRun = 2000, ExampleDistribution = VowpalWabbitExampleDistribution.RoundRobin }; using (var vw = new VowpalWabbitThreadedLearning(settings)) { using (var vwManaged = vw.Create <MyExample>()) { var prediction = await vwManaged.Learn(example, label, VowpalWabbitPredictionType.Scalar); } var saveModelTask = vw.SaveModel("m1.model"); await vw.Complete(); await saveModelTask; } }
public void MinThreeAMinPlus() { int a = 0; int b = 1; int c = 10; int min = MyExample.MinThree(a, b, c); Assert.Equal(a, min); }
public void MinThreeRavnPlus() { int a = 98338; int b = 98338; int c = 98338; int min = MyExample.MinThree(a, b, c); Assert.Equal(a, min); }
public void MinThreeBMinMinus() { int a = -1000; int b = -50100; int c = -7298; int min = MyExample.MinThree(a, b, c); Assert.Equal(b, min); }
public void MinThreeBMinPlus() { int a = 92837; int b = 748; int c = 91382343; int min = MyExample.MinThree(a, b, c); Assert.Equal(b, min); }
public void MinThreeAMinMinus() { int a = -1000; int b = -500; int c = 10; int min = MyExample.MinThree(a, b, c); Assert.Equal(a, min); }
public void MinThreeRavnMinus() { int a = -298338; int b = -298338; int c = -298338; int min = MyExample.MinThree(a, b, c); Assert.Equal(c, min); }
public void MinThreeCMinPlus() { int a = 92837; int b = 748; int c = 88; int min = MyExample.MinThree(a, b, c); Assert.Equal(c, min); }
public void Plus() { double[,] mas = new double[, ] { { 1, 2, 3 }, { 4, 5, 10 }, { 28, 99, 0 } }; int n = 3; var result = MyExample.MaxElementDiagonal(mas, n); var otvet = 99; Assert.Equal(result, otvet); }
public void One() { double[,] mas = new double[, ] { { 88, -66, -24 }, { -4, -5, -10 }, { -28, -99, 0 } }; int n = 3; var result = MyExample.MaxElementDiagonal(mas, n); var otvet = 88; Assert.Equal(result, otvet); }
public void OneTwo() { double[,] mas = new double[, ] { { 1, 2, 3 }, { 1, 2, 3 }, { 1, 2, 3 }, { 1, 2, 3 } }; int n = 3; int m = 4; var result = MyExample.SumChetIndexMassiv(mas, n, m); var otvet = 12; Assert.Equal(result, otvet); }
public void Nulleble() { double[,] mas = new double[, ] { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; int n = 3; int m = 4; var result = MyExample.SumChetIndexMassiv(mas, n, m); var otvet = 0; Assert.Equal(result, otvet); }
public static void AnnotationExample() { using (var vw = new VowpalWabbit<MyExample>(new VowpalWabbitSettings { EnableStringExampleGeneration = true })) { var ex = new MyExample { Income = 40, Age = 25 }; var label = new SimpleLabel { Label = 1 }; var str = vw.Serializer.Create(vw.Native).SerializeToString(ex, label); // 1 |p Income:4 | Age25 vw.Learn(ex, label); var prediction = vw.Predict(ex, VowpalWabbitPredictionType.Scalar); } }
public static void MultiThreadedPrediction() { var example = new MyExample { Income = 40, Age = 25 }; var vwModel = new VowpalWabbitModel("-t -i m1.model"); using (var pool = new VowpalWabbitThreadedPrediction<MyExample>(vwModel)) { // thread-safe using (var vw = pool.GetOrCreate()) { // vw.Value is not thread-safe vw.Value.Predict(example); } // thread-safe pool.UpdateModel(new VowpalWabbitModel("-t -i m2.model")); } }
public static void AnnotationExample() { using (var vw = new VowpalWabbit <MyExample>(new VowpalWabbitSettings(enableStringExampleGeneration: true))) { var ex = new MyExample { Income = 40, Age = 25 }; var label = new SimpleLabel { Label = 1 }; var str = vw.Serializer.Create(vw.Native).SerializeToString(ex, label); // 1 |p Income:4 | Age25 vw.Learn(ex, label); var prediction = vw.Predict(ex, VowpalWabbitPredictionType.Scalar); } }
private void MethodYes(Button bt) { if (trenings[count].MyExamples.Count > 0) { MyExample ex = trenings[count].MyExamples.First(); string examplle = ex.Example; string tire = "" + '\u2014'; textblockExample.Text = examplle?.Replace("--", tire); textblockContext.Text = "Контекст:"; } bt.Background = backgroundGreen; border.Background = backgroundGreen; textBlockAnswer.Text = esAnswer; buttonsix.Content = strFront; buttonsix.FontSize = 24; buttonsix.Foreground = buttonForegroundBlue; trenings[count].TrueAnswer++; countAnswerTrue++; }
public static void MultiThreadedPrediction() { var example = new MyExample { Income = 40, Age = 25 }; var vwModel = new VowpalWabbitModel("-t -i m1.model"); using (var pool = new VowpalWabbitThreadedPrediction <MyExample>(vwModel)) { // thread-safe using (var vw = pool.GetOrCreate()) { // vw.Value is not thread-safe vw.Value.Predict(example); } // thread-safe pool.UpdateModel(new VowpalWabbitModel("-t -i m2.model")); } }
public static int AddNewExamle(string str, int wordid) { using (var context = new ApplicationContext()) { try { var tr = new MyExample() { Example = str, WordId = wordid }; context.MyExamples.Add(tr); context.SaveChanges(); return(tr.ExampleId); } catch (Exception e) { MessageBox.Show(e.Message + " " + MethodBase.GetCurrentMethod().DeclaringType.FullName, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error); return(0); } } }