Exemplo n.º 1
0
        //计算Weights和Bias的梯度
        private void ComputeGradient(TensorOld error)
        {
            var inputData = ForwardInput.GetRawValues();
            var errorData = error.GetRawValues();
            var features  = WeightsGradient.shape[0];

            Parallel.For(0, features, i =>
            {
                Parallel.For(0, UnitCount, j =>
                {
                    var weightSum = 0d;
                    var biasSum   = 0d;
                    for (int k = 0; k < sampleStartIndex.Length; k++)
                    {
                        weightSum += inputData[sampleStartIndex[k] + i] * errorData[errorStartIndex[k] + j];
                        biasSum   += errorData[errorStartIndex[k] + j];
                    }
                    WeightsGradient[i, j]          = weightSum;
                    BiasGradient.GetRawValues()[j] = biasSum;
                });
            });
        }
Exemplo n.º 2
0
        public Task <HttpResponseMessage> ForwardAsync(LoggingContext loggingContext, string forwardTarget)
        {
            if (string.IsNullOrWhiteSpace(forwardTarget))
            {
                throw new ArgumentNullException(nameof(forwardTarget), nameof(forwardTarget) + " should not be null or whitespace");
            }

            string href = PlatformResource?.ForwardLink?.Href;

            if (string.IsNullOrWhiteSpace(href))
            {
                throw new CapabilityNotAvailableException("Link to forward AudioVideoInvitation is not available.");
            }

            Uri forwardLink = UriHelper.CreateAbsoluteUri(BaseUri, href);

            var input = new ForwardInput()
            {
                To = forwardTarget
            };

            return(PostRelatedPlatformResourceAsync(forwardLink, input, new ResourceJsonMediaTypeFormatter(), loggingContext));
        }