private static void PostProcessStatements(StatementBlock block, RandomGenerator random) { MulToShiftTransform.Run(block); NormalizeBinOpTransform.Run(block); ExpansionTransform.Run(block); ShuffleTransform.Run(block, random); ConvertVariables.Run(block); }
/// <summary> /// This method ensures that the data meets the requirements of this trainer and its /// subclasses, injects necessary transforms, and throws if it couldn't meet them. /// </summary> /// <param name="ch">The channel</param> /// <param name="examples">The training examples</param> /// <param name="weightSetCount">Gets the length of weights and bias array. For binary classification and regression, /// this is 1. For multi-class classification, this equals the number of classes on the label.</param> /// <returns>A potentially modified version of <paramref name="examples"/></returns> private RoleMappedData PrepareDataFromTrainingExamples(IChannel ch, RoleMappedData examples, out int weightSetCount) { ch.AssertValue(examples); CheckLabel(examples, out weightSetCount); examples.CheckFeatureFloatVector(); var idvToShuffle = examples.Data; IDataView idvToFeedTrain; if (idvToShuffle.CanShuffle) { idvToFeedTrain = idvToShuffle; } else { var shuffleArgs = new ShuffleTransform.Arguments { PoolOnly = false, ForceShuffle = _args.Shuffle }; idvToFeedTrain = new ShuffleTransform(Host, shuffleArgs, idvToShuffle); } ch.Assert(idvToFeedTrain.CanShuffle); var roles = examples.Schema.GetColumnRoleNames(); var examplesToFeedTrain = new RoleMappedData(idvToFeedTrain, roles); ch.AssertValue(examplesToFeedTrain.Schema.Label); ch.AssertValue(examplesToFeedTrain.Schema.Feature); if (examples.Schema.Weight != null) { ch.AssertValue(examplesToFeedTrain.Schema.Weight); } int numFeatures = examplesToFeedTrain.Schema.Feature.Type.VectorSize; ch.Check(numFeatures > 0, "Training set has no features, aborting training."); return(examplesToFeedTrain); }