Example #1
0
 public double[] GetOutputs(ExecutionSequence executionSequence)
 {
     using (_inputs.Read(executionSequence))
     {
         return(_inputs.InMemoryData);
     }
 }
Example #2
0
        internal static List <string> MapSequence(string p_sequenceFile, string p_directory, bool p_replace)
        {
            List <string>     result = new List <string>();
            string            auxPath;
            ExecutionSequence sequence;

            if (!File.Exists(Path.Combine(sequenceDirectory, p_sequenceFile + ".json")))
            {
                throw new FileNotFoundException("Sequence file not found: " + p_sequenceFile);
            }

            sequence = ExecutionSequence.load(Path.Combine(sequenceDirectory, p_sequenceFile + ".json"));
            sequence.Itens.Sort((i1, i2) => i1.Sequence.CompareTo(i2.Sequence));

            sequence.Itens.ForEach((item) =>
            {
                if (!string.IsNullOrEmpty(item.RelativePath) && !Path.IsPathRooted(item.RelativePath))
                {
                    auxPath = Path.GetFullPath(Path.Combine(p_directory, item.RelativePath));
                }
                else
                {
                    auxPath = p_directory;
                }
                result.AddRange(MapFiles(item.Configuration, auxPath, p_replace));
            });

            return(result);
        }
Example #3
0
 public double[] GetBiases(ExecutionSequence executionSequence)
 {
     using (_biases.Read(executionSequence))
     {
         return(_biases.InMemoryData);
     }
 }
Example #4
0
 public double[] GetDeltas(ExecutionSequence executionSequence)
 {
     using (_layerDeltas.Read(executionSequence))
     {
         return(_layerDeltas.InMemoryData);
     }
 }
Example #5
0
 public double[] GetWeights(ExecutionSequence executionSequence)
 {
     using (_weights.Read(executionSequence))
     {
         return(_weights.InMemoryData);
     }
 }
Example #6
0
 /// <summary>
 /// Generates a string with the Routing Rule contents
 /// </summary>
 /// <returns>A <see cref="string"/> contaning the Routing Rule information</returns>
 public override string ToString()
 {
     return(string.Format("{0}\n{1}\n{2}",
                          FormatForToString("Type", this.GetType().ToString()),
                          FormatForToString("Sequence", ExecutionSequence.ToString()),
                          FormatForToString("Smtp Key", SmtpConfigurationKey)));
 }
Example #7
0
 public void SetWeights(ExecutionSequence executionSequence, double[] weights)
 {
     if (weights.Length != _weightLength)
     {
         throw new ArgumentException($"weight array length ({weights.Length}) does not match required ({_weightLength})", nameof(weights));
     }
     _weights.Update(weights, executionSequence);
 }
Example #8
0
 public void ExecuteBackwardPass(ExecutionSequence executionSequence)
 {
     // Backward pass.
     for (var i = Layers.Length - 1; i >= 0; i--)
     {
         Layers[i].BackwardPass(executionSequence);
     }
 }
Example #9
0
 public void SetInputs(ExecutionSequence executionSequence, double[] inputs)
 {
     if (Layers.Length < 1)
     {
         throw new NerotiqException("Network does not have an input layer");
     }
     (Layers[0] as IInput)?.SetInputs(executionSequence, inputs);
 }
Example #10
0
 public void ExecuteForwardPass(ExecutionSequence executionSequence)
 {
     // Forward pass.
     for (var i = 0; i < Layers.Length; i++)
     {
         Layers[i].ForwardPass(executionSequence);
     }
 }
Example #11
0
 public void SetInputs(ExecutionSequence executionSequence, double[] inputs)
 {
     if (inputs.Length != NodeCount)
     {
         throw new ArgumentException($"input array length ({inputs.Length}) does not match input layer size ({NodeCount})", nameof(inputs));
     }
     _inputs.Update(inputs, executionSequence);
 }
Example #12
0
 public void BackwardPass(ExecutionSequence executionSequence)
 {
     executionSequence.EnqueueNDRangeKernel(
         _backwardKernel,
         1,
         null,
         new IntPtr [] { new IntPtr(NodeCount) },
         null
         );
 }
Example #13
0
 public void Update(ExecutionSequence executionSequence)
 {
     executionSequence.EnqueueNDRangeKernel(
         _updateKernel,
         _dimensions,
         null,
         new IntPtr [] { new IntPtr(_nodeCount) },
         null
         );
 }
Example #14
0
        private static void initSeq(Dictionary <string, string> inputArgs)
        {
            ExecutionSequence file;
            string            sequenceFileName = "";
            List <string>     mappersFilesNames;


            try
            {
                sequenceFileName  = Path.GetFullPath(Path.Combine(FileMapper.sequenceDirectory, inputArgs.GetValueOrDefault("INITSEQ") + ".json"));
                mappersFilesNames = inputArgs.GetValueOrDefault("SEQ").Split(" ").ToList();

                file = new ExecutionSequence()
                {
                    Name  = inputArgs.GetValueOrDefault("INITSEQ"),
                    Itens = (from item in mappersFilesNames
                             select new ExecutionItem()
                    {
                        Sequence = mappersFilesNames.IndexOf(item) + 1,
                        Configuration = item
                    }
                             ).ToList()
                };

                file.save(sequenceFileName);
                Console.WriteLine("Saved: " + inputArgs.GetValueOrDefault("INITSEQ"));

                Console.WriteLine("Do you want to open the generated file? (y or n)");
                if (Console.ReadLine().Equals("Y", StringComparison.InvariantCultureIgnoreCase))
                {
                    var p1 = new Process();
                    p1.StartInfo = new ProcessStartInfo(@sequenceFileName)
                    {
                        UseShellExecute = true
                    };
                    p1.Start();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #15
0
 public void SetTargets(ExecutionSequence executionSequence, double[] targets)
 {
     if (targets.Length != NodeCount)
     {
         throw new NerotiqException($"target value array length ({targets.Length}) does not match layer size ({NodeCount})");
     }
     if (_layerTargets == null)
     {
         try {
             _layerTargets = new GpuMatrix((ushort)NodeCount, 1, executionSequence.Context);
         } catch (Exception ex)
         {
             throw new NerotiqException($"Error allocating delta buffer", ex);
         }
         _layerTargets.SetKernelArg(
             _backwardKernel,
             11
             );
     }
     _layerTargets.Update(targets, executionSequence);
 }
Example #16
0
        public double[] GetOutputs(ExecutionSequence executionSequence)
        {
            var lastLayer = Layers.Last();

            return(lastLayer.GetOutputs(executionSequence));
        }
Example #17
0
        public double[] GetInputs(ExecutionSequence executionSequence)
        {
            var firstLayer = Layers.First();

            return(firstLayer.GetOutputs(executionSequence));
        }
Example #18
0
 public TestScaffold()
 {
     Context           = new ExecutionContext();
     ExecutionSequence = new ExecutionSequence(Context);
 }
Example #19
0
 public void SetBiases(ExecutionSequence executionSequence, double[] biases)
 {
     _biases.Update(biases, executionSequence);
 }
Example #20
0
 public void UpdateParameters(ExecutionSequence executionSequence)
 {
     _update.Update(executionSequence);
 }
Example #21
0
 public void BackwardPass(ExecutionSequence executionSequence)
 {
     // Nothing to be done.
 }
Example #22
0
 public void SetOutputs(ExecutionSequence executionSequence, double[] outputs)
 {
     _layerOutputs.Update(outputs, executionSequence);
 }