コード例 #1
0
 public void AddSigmoidGradient(WeightTensor src)
 {
     if (m_TGradient == null)
     {
         allocator   = TensorAllocator.Allocator(DeviceId);
         m_TGradient = new Tensor(allocator, DType.Float32, src.TWeight.Sizes);
         Ops.SigmoidD(m_TGradient, src.TWeight, src.TGradient);
     }
     else
     {
         Ops.AddSigmoidD(m_TGradient, m_TGradient, src.TWeight, src.TGradient);
     }
 }
コード例 #2
0
        public IWeightMatrix Sigmoid(IWeightMatrix w)
        {
            var m   = w as WeightTensor;
            var res = weightTensorFactory.CreateWeightTensor(m.Rows, m.Columns, deviceId);

            Ops.Sigmoid(res.TWeight, m.TWeight);

            if (this.needs_backprop)
            {
                Action backward = () =>
                {
                    Ops.AddSigmoidD(m.TGradient, m.TGradient, res.TWeight, res.TGradient);
                };
                this.backprop.Add(backward);
            }

            return(res);
        }