Пример #1
0
 public FCNetwork(FCNetworkConfig config)
 {
     Inputs = new NativeArray <float>(config.Layers[0].NumNeurons, Allocator.Persistent);
     Layers = new FCLayer[config.Layers.Count - 1];
     for (int l = 0; l < Layers.Length; l++)
     {
         Layers[l] = new FCLayer(config.Layers[l + 1].NumNeurons, config.Layers[l].NumNeurons);
     }
     Config = config;
 }
Пример #2
0
        // Todo: merge with the one from NeuralJobs (note: different activation function?)
        public static JobHandle ForwardPass(NativeArray <float> input, FCLayer layer, JobHandle h)
        {
            const int numThreads = 8;

            var b = new CopyParallelJob();

            b.From = layer.Biases;
            b.To   = layer.Outputs;
            h      = b.Schedule(layer.Outputs.Length, layer.Outputs.Length / numThreads, h);

            var d = new DotParallelJob();

            d.Input   = input;
            d.Weights = layer.Weights;
            d.Output  = layer.Outputs;
            h         = d.Schedule(layer.Outputs.Length, layer.Outputs.Length / numThreads, h);

            var s = new SigmoidAssignParallelJob();

            s.Data = layer.Outputs;
            h      = s.Schedule(layer.Outputs.Length, layer.Outputs.Length / numThreads, h);

            return(h);
        }