// method to initialize network public void InitializeNetwork() { NeuralNet = new Network(); trainingInputs = new List <double[]>(); double[] tempInput; for (int i = 0; i < Inputs.Count(); i++) { tempInput = new double[Inputs[0].GetLength(0)]; for (int j = 0; j < Inputs[0].GetLength(0); j++) { tempInput[j] = Inputs[i][j]; } trainingInputs.Add(tempInput); } trainingOutputs = new List <double[]>(); for (int i = 0; i < Outputs.Count(); i++) { tempInput = new double[Outputs[0].GetLength(0)]; for (int j = 0; j < Outputs[0].GetLength(0); j++) { tempInput[j] = Outputs[i][j]; } trainingOutputs.Add(tempInput); } NeuralNet.NumInputs = NumInputs; NeuralNet.NumHidden = NumHidden; NeuralNet.NumOutputs = NumOutputs; NeuralNet.WeightInitSTD = WeightInitSTD; NeuralNet.InitializeRandomNetwork(); MomentumMat1 = new double[NumHidden, NumInputs + 1]; MomentumMat2 = new double[NumOutputs, NumHidden + 1]; }
public static IEnumerable <(Money value, int count)> GetIndistinguishableOutputs(this Transaction me) { var ret = new List <(Money Value, int count)>(); foreach (Money v in me.Outputs.Select(x => x.Value).Distinct()) { ret.Add((v, me.Outputs.Count(x => x.Value == v))); } return(ret); }
protected override void ExecuteInternal() { var parentDirectory = Directory.GetParent(BaseConfigPath); var configFileName = Path.GetFileNameWithoutExtension(BaseConfigPath); if (!string.IsNullOrEmpty(TransformFilePath) && File.Exists(TransformFilePath)) { var updatedConfig = TransformationHelper.Transform(File.ReadAllText(BaseConfigPath), File.ReadAllText(TransformFilePath)); if (updatedConfig is null) { return; } updatedConfig.Save(BaseConfigPath); if (Build.Configuration.Debug) { Log.LogMessage("*************** Transformed app.config ******************************"); Log.LogMessage(updatedConfig.ToString()); } } switch (Build.Configuration.AppConfig.Strategy) { case Models.AppConfigStrategy.BundleAll: Outputs = parentDirectory.EnumerateFiles() .Select(x => new TaskItem(x.FullName)); Log.LogMessage($"All app.config's will be bundled. {string.Join(", ", parentDirectory.EnumerateFiles().Select(x => x.Name))}"); break; case Models.AppConfigStrategy.BundleNonStandard: var standardConfigs = new[] { "app.debug.config", "app.release.config", "app.store.config", "app.adhoc.config" }; Outputs = parentDirectory.EnumerateFiles() .Where(x => !standardConfigs.Any(s => s.Equals(x.Name, StringComparison.InvariantCultureIgnoreCase))) .Select(x => new TaskItem(x.FullName)); if (Outputs.Count() > 1) { Log.LogMessage($"The app.config will be bundled with the following configurations. {string.Join(", ", Outputs.Select(x => Path.GetFileName(x.ItemSpec)))}"); } break; default: Outputs = new[] { new TaskItem(BaseConfigPath) }; break; } }
/// <summary> /// Gets the arguments. /// </summary> /// <returns></returns> public override string GetArguments() { string command = string.Empty; string includeDir = string.IsNullOrEmpty(Include) ? string.Empty : @" -I""" + Include + @""""; command += includeDir; foreach (string opt in Options) { command += string.Format(" {0} ", opt); } //#if !Linux if (GenerateDebugInfo) { if (Version != null && Version.Major >= 5) { command += " -G "; } else { command += " -G0 "; } } //#endif if (Sources.Count() == 0) { throw new CudafyCompileException(CudafyCompileException.csNO_SOURCES); } bool generateBinary = (CompileMode & eCudafyCompileMode.Binary) == eCudafyCompileMode.Binary; if (generateBinary) { command += " -c "; } foreach (string src in Sources) { command += string.Format(@" ""{0}"" ", src); } if (!generateBinary && Outputs.Count() == 1) { command += string.Format(@" -o ""{0}"" ", Outputs.Take(1).FirstOrDefault()); } if (!generateBinary) { command += " -ptx"; } return(command); }
public async Task Execute(BuildTasks build_tasks) { if (started_task.TrySetResult(true)) { var watch = new System.Diagnostics.Stopwatch(); try { Log("Launching task"); var deps = Dependencies.ToArray(); var dep_tasks = new Task [deps.Length]; for (int i = 0; i < deps.Length; i++) { dep_tasks [i] = deps [i].Execute(build_tasks); } Log("Waiting for dependencies to complete."); await Task.WhenAll(dep_tasks); Log("Done waiting for dependencies."); // We can only check if we're up-to-date after executing dependencies. if (IsUptodate) { if (Outputs.Count() > 1) { Driver.Log(3, "Targets '{0}' are up-to-date.", string.Join("', '", Outputs.ToArray())); } else { Driver.Log(3, "Target '{0}' is up-to-date.", Outputs.First()); } completed_task.SetResult(false); } else { Driver.Log(3, "Target(s) {0} must be rebuilt.", string.Join(", ", Outputs.ToArray())); Log("Dependencies are complete."); await build_tasks.AcquireSemaphore(); try { Log("Executing task"); watch.Start(); await ExecuteAsync(); watch.Stop(); Log("Completed task {0} s", watch.Elapsed.TotalSeconds); completed_task.SetResult(true); } finally { build_tasks.ReleaseSemaphore(); } } } catch (Exception e) { Log("Completed task in {0} s with exception: {1}", watch.Elapsed.TotalSeconds, e.Message); completed_task.SetException(e); throw; } } else { Log("Waiting for started task"); await completed_task.Task; Log("Waited for started task"); } }
public int GetOutputCount() { return(Outputs.Count()); }