public void Testl_ShakeInputTransformVectorAdd() { /*using (*/ var host = EnvHelper.NewTestEnvironment(); { var inputs = new[] { new SHExampleA() { X = new float[] { 0, 1 } }, new SHExampleA() { X = new float[] { 2, 3 } } }; var data = DataViewConstructionUtils.CreateFromEnumerable(host, inputs); var args = new ShakeInputTransform.Arguments { inputColumn = "X", inputFeaturesInt = new[] { 0, 1 }, outputColumns = new[] { "yo" }, values = "-10,10;-100,100", aggregation = ShakeInputTransform.ShakeAggregation.add }; var trv = new ExampleValueMapperVector(); if (trv == null) { throw new Exception("Invalid"); } var shake = new ShakeInputTransform(host, args, data, new IValueMapper[] { trv }); using (var cursor = shake.GetRowCursor(shake.Schema)) { var outValues = new List <float>(); var colGetter = cursor.GetGetter <VBuffer <float> >(SchemaHelper._dc(1, cursor)); while (cursor.MoveNext()) { VBuffer <float> got = new VBuffer <float>(); colGetter(ref got); outValues.AddRange(got.DenseValues()); } if (outValues.Count != 4) { throw new Exception("expected 4"); } } } }
public void Testl_ShakeInputTransformVector() { using (var host = EnvHelper.NewTestEnvironment()) { var inputs = new[] { new SHExampleA() { X = new float[] { 0, 1 } }, new SHExampleA() { X = new float[] { 2, 3 } } }; var data = host.CreateStreamingDataView(inputs); var args = new ShakeInputTransform.Arguments { inputColumn = "X", inputFeaturesInt = new[] { 0, 1 }, outputColumns = new[] { "yo" }, values = "-10,10;-100,100" }; var trv = new ExampleValueMapperVector(); if (trv == null) { throw new Exception("Invalid"); } var shake = new ShakeInputTransform(host, args, data, new IValueMapper[] { trv }); using (var cursor = shake.GetRowCursor(i => true)) { var outValues = new List <float>(); var colGetter = cursor.GetGetter <VBuffer <float> >(1); while (cursor.MoveNext()) { VBuffer <float> got = new VBuffer <float>(); colGetter(ref got); outValues.AddRange(got.DenseValues()); } if (outValues.Count != 16) { throw new Exception("expected 16"); } } } }