示例#1
0
        public static JobHandle ForwardPass(FCNetwork net, JobHandle handle = new JobHandle())
        {
            NativeArray <float> last = net.Inputs;

            for (int l = 0; l < net.Layers.Length; l++)
            {
                var layer = net.Layers[l];

                const int numThreads = 8;

                var b = new CopyParallelJob();
                b.From = layer.Biases;
                b.To   = layer.Outputs;
                handle = b.Schedule(layer.Outputs.Length, layer.Outputs.Length / numThreads, handle);

                var d = new DotParallelJob();
                d.Input   = last;
                d.Weights = layer.Weights;
                d.Output  = layer.Outputs;
                handle    = d.Schedule(layer.Outputs.Length, layer.Outputs.Length / numThreads, handle);

                var s = new SigmoidAssignParallelJob();
                s.Data = layer.Outputs;
                handle = s.Schedule(layer.Outputs.Length, layer.Outputs.Length / numThreads, handle);

                last = layer.Outputs;
            }

            return(handle);
        }
示例#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);
        }