public void CanTrainSupervised() { using var fastText = new FastTextWrapper(loggerFactory: _loggerFactory); string outPath = Path.Combine(_tempDir, "cooking"); var args = new SupervisedArgs(); var tuneArgs = new AutotuneArgs(); fastText.Supervised("cooking.train.txt", outPath, args, tuneArgs, true); fastText.IsModelReady().Should().BeTrue(); fastText.GetModelDimension().Should().Be(100); fastText.ModelPath.Should().Be(outPath + ".bin"); AssertLabels(fastText.GetLabels()); File.Exists(outPath + ".bin").Should().BeTrue(); File.Exists(outPath + ".vec").Should().BeTrue(); var debugArgs = DebugArgs.Load("_train.txt"); AssertSupervisedArgs(args, debugArgs.ExternalArgs); AssertSupervisedArgs(args, debugArgs.ConvertedArgs); AssertAutotuneArgs(tuneArgs, debugArgs.ExternalTune); AssertAutotuneArgs(tuneArgs, debugArgs.ConvertedTune); debugArgs.ExternalInput.Should().Be("cooking.train.txt"); debugArgs.ConvertedInput.Should().Be("cooking.train.txt"); debugArgs.ExternalOutput.Should().Be(outPath); debugArgs.ConvertedOutput.Should().Be(outPath); }
public DMDConfig() { DebugArgs.Reset(); ReleaseArgs.Reset(); ASTCache.FinishedParsing += parsedSources; ASTCache.FinishedUfcsCaching += new Action(ASTCache_FinishedUfcsCaching); }
public void CanAutotuneSupervisedModel() { using var fastText = new FastTextWrapper(loggerFactory: _loggerFactory); string outPath = Path.Combine(_tempDir, "cooking"); var args = new SupervisedArgs { bucket = 2100000, dim = 250, epoch = 10, loss = LossName.HierarchicalSoftmax, lr = 0.5, maxn = 5, minn = 2, neg = 6, seed = 42, t = 0.0002, thread = 10, verbose = 1, ws = 6, minCount = 2, saveOutput = true, wordNgrams = 2, lrUpdateRate = 110, minCountLabel = 1 }; var autotuneArgs = new AutotuneArgs { Duration = 30, Metric = "precisionAtRecall:30", Predictions = 2, ValidationFile = "cooking.valid.txt" }; fastText.Supervised("cooking.train.txt", outPath, args, autotuneArgs, true); fastText.IsModelReady().Should().BeTrue(); fastText.GetModelDimension().Should().Be(250); fastText.ModelPath.Should().Be(outPath + ".bin"); File.Exists(outPath + ".bin").Should().BeTrue(); File.Exists(outPath + ".vec").Should().BeTrue(); var debugArgs = DebugArgs.Load("_train.txt"); AssertSupervisedArgs(args, debugArgs.ExternalArgs); AssertSupervisedArgs(args, debugArgs.ConvertedArgs); AssertAutotuneArgs(autotuneArgs, debugArgs.ExternalTune); AssertAutotuneArgs(autotuneArgs, debugArgs.ConvertedTune); debugArgs.ExternalInput.Should().Be("cooking.train.txt"); debugArgs.ConvertedInput.Should().Be("cooking.train.txt"); debugArgs.ExternalOutput.Should().Be(outPath); debugArgs.ConvertedOutput.Should().Be(outPath); }
public GameArgs(GameArgs args) { Input = new InputSettingsArgs(args.Input); Content = new ContentManagerArgs(args.Content); Graphics = new GraphicsRendererArgs(args.Graphics); States = new GameStateManagerArgs(args.States); Time = new TimeManagerArgs(args.Time); Window = new GameWindowArgs(args.Window); Debug = new DebugArgs(args.Debug); }
// Constructor(s) public GameArgs() { Input = new InputSettingsArgs(); Content = new ContentManagerArgs(); Graphics = new GraphicsRendererArgs(); States = new GameStateManagerArgs(); Time = new TimeManagerArgs(); Window = new GameWindowArgs(); Debug = new DebugArgs(); }
public override void Write(string message) { EventHandler <DebugMessageArgs> h = DebugMessage; if (h != null) { DebugArgs args = new DebugArgs { Message = message }; h(this, args); } }
/// <summary> /// Loads the logging settings from the application configuration. /// </summary> /// <param name="config">Application configuration.</param> public void Load(TextFileConfiguration config) { DebugArgs = config.GetOrDefault("debug", string.Empty).Split(',').Where(s => !string.IsNullOrEmpty(s)) .ToList(); // Get the minimum log level. The default is either Information or Debug depending on the DebugArgs. LogLevel = DebugArgs.Any() ? LogLevel.Debug : LogLevel.Info; string logLevelArg = config.GetOrDefault("loglevel", string.Empty); if (!string.IsNullOrEmpty(logLevelArg)) { LogLevel = LogLevel.FromString(logLevelArg); } }
/// <summary> /// Process a debug incidence, depending on the operationMode /// </summary> /// <param name="data"></param> public void AcceptDebug(DebugArgs data) { if (operationMode == DebugParameters.Disabled) { return; } lastIncidence = data; if (operationMode == DebugParameters.ToConsole || operationMode == DebugParameters.ToConsoleAndFile) { SendToConsole(); } if (operationMode == DebugParameters.ToFile || operationMode == DebugParameters.ToConsoleAndFile) { SendToFile(); } }
public override bool ParseArgs(IScenarioContent content, ref DebugArgs args, out string error) { #if UNITY_EDITOR // debug log "message"; // debug warning "var = " var; // debug error "str0" var0 "str1" var1 var2 var3 "str2"...; if (content.length < 3) { error = GetLengthErrorString(); return(false); } if (!s_EditorLowerLogTypeStrings.Contains(content[1].ToLower())) { error = string.Format( "{0} ParseArgs error: LogType `{1}` is not defined.", typeName, content[1]); return(false); } args.logType = (LogType)Enum.Parse(typeof(LogType), content[1], true); List <string> messages = new List <string>(); int startIndex = 2; int endIndex = 2; string str; while (startIndex < content.length) { if (GetNextString(content, startIndex, ref endIndex, out str, out error)) { messages.Add(str); startIndex = endIndex + 1; } else { return(false); } } args.message = string.Join(" ", messages.ToArray()); #endif error = null; return(true); }
//---------------------------------------------------------------------------------------------------- // Class Methods /// <summary> Fires when our debugger reports that a new message has been recieved. </summary> /// <param name="source"></param> /// <param name="args"></param> private void Instance_DebugMessageRecieved(object source, DebugArgs args) { Debug.Log(args.message); }
internal static DebugArgs Load(string path) { var result = new DebugArgs(); var lines = File.ReadAllLines(path); int idx = -1; if (lines[++idx] != "= eargs") { throw new InvalidOperationException(); } result.ExternalInput = lines[++idx]; result.ExternalOutput = lines[++idx]; result.ExternalArgs.lr = double.Parse(lines[++idx]); result.ExternalArgs.lrUpdateRate = int.Parse(lines[++idx]); result.ExternalArgs.dim = int.Parse(lines[++idx]); result.ExternalArgs.ws = int.Parse(lines[++idx]); result.ExternalArgs.epoch = int.Parse(lines[++idx]); result.ExternalArgs.minCount = int.Parse(lines[++idx]); result.ExternalArgs.minCountLabel = int.Parse(lines[++idx]); result.ExternalArgs.neg = int.Parse(lines[++idx]); result.ExternalArgs.wordNgrams = int.Parse(lines[++idx]); result.ExternalArgs.loss = (LossName)int.Parse(lines[++idx]); result.ExternalArgs.model = (ModelName)int.Parse(lines[++idx]); result.ExternalArgs.bucket = int.Parse(lines[++idx]); result.ExternalArgs.minn = int.Parse(lines[++idx]); result.ExternalArgs.maxn = int.Parse(lines[++idx]); result.ExternalArgs.thread = int.Parse(lines[++idx]); result.ExternalArgs.t = double.Parse(lines[++idx]); result.ExternalArgs.LabelPrefix = lines[++idx]; result.ExternalArgs.verbose = int.Parse(lines[++idx]); result.ExternalArgs.PretrainedVectors = lines[++idx]; result.ExternalArgs.saveOutput = int.Parse(lines[++idx]) == 1; result.ExternalArgs.seed = int.Parse(lines[++idx]); result.ExternalArgs.qout = int.Parse(lines[++idx]) == 1; result.ExternalArgs.retrain = int.Parse(lines[++idx]) == 1; result.ExternalArgs.qnorm = int.Parse(lines[++idx]) == 1; result.ExternalArgs.cutoff = ulong.Parse(lines[++idx]); result.ExternalArgs.dsub = ulong.Parse(lines[++idx]); result.ExternalTune.ValidationFile = lines[++idx]; result.ExternalTune.Metric = lines[++idx]; result.ExternalTune.Predictions = int.Parse(lines[++idx]); result.ExternalTune.Duration = int.Parse(lines[++idx]); result.ExternalTune.ModelSize = lines[++idx]; result.ExternalTune.Verbose = int.Parse(lines[++idx]); if (lines[++idx] != "= args") { throw new InvalidOperationException(); } result.ConvertedInput = lines[++idx]; result.ConvertedOutput = lines[++idx]; result.ConvertedArgs.lr = double.Parse(lines[++idx]); result.ConvertedArgs.lrUpdateRate = int.Parse(lines[++idx]); result.ConvertedArgs.dim = int.Parse(lines[++idx]); result.ConvertedArgs.ws = int.Parse(lines[++idx]); result.ConvertedArgs.epoch = int.Parse(lines[++idx]); result.ConvertedArgs.minCount = int.Parse(lines[++idx]); result.ConvertedArgs.minCountLabel = int.Parse(lines[++idx]); result.ConvertedArgs.neg = int.Parse(lines[++idx]); result.ConvertedArgs.wordNgrams = int.Parse(lines[++idx]); result.ConvertedArgs.loss = (LossName)int.Parse(lines[++idx]); result.ConvertedArgs.model = (ModelName)int.Parse(lines[++idx]); result.ConvertedArgs.bucket = int.Parse(lines[++idx]); result.ConvertedArgs.minn = int.Parse(lines[++idx]); result.ConvertedArgs.maxn = int.Parse(lines[++idx]); result.ConvertedArgs.thread = int.Parse(lines[++idx]); result.ConvertedArgs.t = double.Parse(lines[++idx]); result.ConvertedArgs.LabelPrefix = lines[++idx]; result.ConvertedArgs.verbose = int.Parse(lines[++idx]); result.ConvertedArgs.PretrainedVectors = lines[++idx]; result.ConvertedArgs.saveOutput = int.Parse(lines[++idx]) == 1; result.ConvertedArgs.seed = int.Parse(lines[++idx]); result.ConvertedArgs.qout = int.Parse(lines[++idx]) == 1; result.ConvertedArgs.retrain = int.Parse(lines[++idx]) == 1; result.ConvertedArgs.qnorm = int.Parse(lines[++idx]) == 1; result.ConvertedArgs.cutoff = ulong.Parse(lines[++idx]); result.ConvertedArgs.dsub = ulong.Parse(lines[++idx]); result.ConvertedTune.ValidationFile = lines[++idx]; result.ConvertedTune.Metric = lines[++idx]; result.ConvertedTune.Predictions = int.Parse(lines[++idx]); result.ConvertedTune.Duration = int.Parse(lines[++idx]); result.ConvertedTune.ModelSize = lines[++idx]; result.ConvertedTune.Verbose = int.Parse(lines[++idx]); return(result); }
public DMDConfig() { DebugArgs.Reset(); ReleaseArgs.Reset(); }
protected override ActionStatus Run(IGameAction gameAction, IScenarioContent content, DebugArgs args, out string error) { #if UNITY_EDITOR string message = args.message; switch (args.logType) { case LogType.Error: Debug.LogError(message); break; case LogType.Assert: Debug.LogAssertion(message); break; case LogType.Warning: Debug.LogWarning(message); break; case LogType.Log: Debug.Log(message); break; case LogType.Exception: DebugException e = new DebugException(message); error = e.ToString(); Debug.LogException(e); return(ActionStatus.Error); default: break; } #endif error = null; return(ActionStatus.Continue); }