示例#1
0
        internal CpuTensorScope(Tensor @this)
        {
            Contract.Requires(@this != null);
            Contract.Requires(@this.Count != 0);

            this.Tensor = @this;

            var tensorImpl = (ITensorHostImpl) @this;
            this._data = Vector<double>.Build.OfStorage( tensorImpl.Data );
            this._diff = Vector<double>.Build.OfStorage( tensorImpl.Diff );
        }
示例#2
0
 public abstract void Fill( Tensor blob );
示例#3
0
 public void ShareDiff(Tensor other)
 {
     switch (this.Location)
     {
         case TensorLocation.Cpu:
             this._diff = other._diff;
             break;
         case TensorLocation.Gpu:
             throw new NotImplementedException();
     }
 }
示例#4
0
        public void ReshapeAs( Tensor other )
        {
            if (other == null)
                throw new ArgumentNullException("other");
            Contract.EndContractBlock();

            this.Reshape(other.Num, other.Channels, other.Height, other.Width);
        }  
示例#5
0
        public void CopyFrom(Tensor other, bool copyDiff = false, bool reshape = false)
        {
            if (other == null)
                throw new ArgumentNullException("other");
            Contract.EndContractBlock();           

            // If reshaping needed we reshape the instance with new memory.
            if (reshape)
                ReshapeAs(other);

            switch (this.Location)
            {
                case TensorLocation.Cpu:
                    using (var @thisCpu = this.OnCpu())
                    using (var @otherCpu = other.OnCpu())
                    {
                        // We copy the data
                        @otherCpu.Data.CopyTo(@thisCpu.Data);

                        // If copying differential is needed, we copy it too.
                        if (copyDiff)
                            @otherCpu.Diff.CopyTo(@thisCpu.Diff);
                    }
                    break;
                case TensorLocation.Gpu:
                    break;
            }

            throw new NotImplementedException();


        }
示例#6
0
        public Tensor( Tensor blob )
        {
            Guard.That(() => blob).IsNotNull();

            ReshapeAs(blob);
        }
示例#7
0
        internal GpuTensorScope(Tensor @this)
        {
            Contract.Requires(@this != null);
            Contract.Requires(@this.Count != 0);

            this.Tensor = @this;
        }
示例#8
0
        public void Setup( Tensor bottom, Tensor top )
        {
            Contract.Requires(bottom != null);
            Contract.Requires(top != null);

            var bottomList = new TensorCollection { bottom };
            var topList = new TensorCollection { top };
            this.Setup( bottomList, topList );
        }
示例#9
0
        public double Forward(Tensor bottom, Tensor top)
        {
            Contract.Requires(bottom != null && top != null);

            Guard.That(() => bottom).IsNotNull();
            Guard.That(() => top).IsNotNull();

            var bottomList = new TensorCollection { bottom };
            var topList = new TensorCollection { top };

            return this.Forward(bottomList, topList);
        }
示例#10
0
        public void Backward(Tensor top, IList<bool> propagateDown, Tensor bottom)
        {
            Contract.Requires(bottom != null && top != null);

            Guard.That(() => bottom).IsNotNull();
            Guard.That(() => top).IsNotNull();

            this.Backward(new TensorCollection { top }, propagateDown, new TensorCollection { bottom });
        }