public ColInfoEx(GcnColumn col, GcnArguments args) { SubtractMean = col.SubMean ?? args.SubMean; NormKind = (col.UseStdDev ?? args.UseStdDev) ? NormalizerKind.StdDev : NormalizerKind.L2Norm; Scale = col.Scale ?? args.Scale; Contracts.CheckUserArg(0 < Scale && Scale < Float.PositiveInfinity, nameof(args.Scale), "scale must be a positive finite value"); }
/// <summary> /// A helper method to create LpNormNormalizer transform for public facing API. /// </summary> /// <param name="env">Host Environment.</param> /// <param name="input">Input <see cref="IDataView"/>. This is the output from previous transform or loader.</param> /// <param name="name">Name of the output column.</param> /// <param name="source">Name of the column to be transformed. If this is null '<paramref name="name"/>' will be used.</param> /// <param name="normKind">The norm to use to normalize each sample.</param> /// <param name="subMean">Subtract mean from each value before normalizing.</param> public static IDataTransform CreateLpNormNormalizer(IHostEnvironment env, IDataView input, string name, string source = null, NormalizerKind normKind = Defaults.NormKind, bool subMean = Defaults.LpSubMean) { var args = new Arguments() { Column = new[] { new Column() { Source = source ?? name, Name = name } }, SubMean = subMean, NormKind = normKind }; return(new LpNormNormalizerTransform(env, args, input)); }
public ColInfoEx(ModelLoadContext ctx, bool normKindSerialized) { Contracts.AssertValue(ctx); // *** Binary format *** // byte: subMean // byte: NormKind // Float: scale SubtractMean = ctx.Reader.ReadBoolByte(); byte normKindVal = ctx.Reader.ReadByte(); Contracts.CheckDecode(Enum.IsDefined(typeof(NormalizerKind), normKindVal)); NormKind = (NormalizerKind)normKindVal; // Note: In early versions, a bool option (useStd) to whether to normalize by StdDev rather than // L2 norm was used. normKind was added in version=verVectorNormalizerSupported. // normKind was defined in a way such that the serialized boolean (0: use StdDev, 1: use L2) is // still valid. Contracts.CheckDecode(normKindSerialized || (NormKind == NormalizerKind.L2Norm || NormKind == NormalizerKind.StdDev)); Scale = ctx.Reader.ReadFloat(); Contracts.CheckDecode(0 < Scale && Scale < Float.PositiveInfinity); }
public ColInfoEx(Column col, Arguments args) { SubtractMean = col.SubMean ?? args.SubMean; NormKind = col.NormKind ?? args.NormKind; Scale = 1; }
/// <include file='doc.xml' path='doc/members/member[@name="LpNormalize"]/*'/> /// <param name="env">The environment.</param> /// <param name="inputColumn">The column containing text to tokenize.</param> /// <param name="outputColumn">The column containing output tokens. Null means <paramref name="inputColumn"/> is replaced.</param> /// <param name="normKind">Type of norm to use to normalize each sample.</param> /// <param name="subMean">Subtract mean from each value before normalizing.</param> public LpNormalizer(IHostEnvironment env, string inputColumn, string outputColumn = null, NormalizerKind normKind = NormalizerKind.L2Norm, bool subMean = false) : this(env, new[] { (inputColumn, outputColumn ?? inputColumn) }, normKind, subMean)