Exemple #1
0
        public I3DTensor AddPadding(int padding)
        {
            var newRows    = _rows + padding * 2;
            var newColumns = _columns + padding * 2;
            var ret        = new Cpu3DTensor(newRows, newColumns, Depth);

            for (var k = 0; k < Depth; k++)
            {
                for (var i = 0; i < newRows; i++)
                {
                    for (var j = 0; j < newColumns; j++)
                    {
                        if (i < padding || j < padding)
                        {
                            continue;
                        }
                        else if (i >= newRows - padding || j >= newColumns - padding)
                        {
                            continue;
                        }
                        ret[i, j, k] = this[i - padding, j - padding, k];
                    }
                }
            }
            return(ret);
        }
Exemple #2
0
        public I3DTensor RemovePadding(int padding)
        {
            var newRows    = _rows - padding * 2;
            var newColumns = _columns - padding * 2;
            var ret        = new Cpu3DTensor(newRows, newColumns, Depth);

            for (var k = 0; k < Depth; k++)
            {
                for (var i = 0; i < newRows; i++)
                {
                    for (var j = 0; j < newColumns; j++)
                    {
                        ret[i, j, k] = this[i + padding, j + padding, k];
                    }
                }
            }
            return(ret);
        }
Exemple #3
0
 public I3DTensor ConvertTo3DTensor(int rows, int columns, int depth)
 {
     if (depth > 1)
     {
         var matrixList = new List <IMatrix>();
         var slice      = Split(depth);
         foreach (var part in slice)
         {
             matrixList.Add(part.ConvertInPlaceToMatrix(rows, columns));
         }
         var ret = new Cpu3DTensor(matrixList);
         return(ret);
     }
     else
     {
         var matrix = ConvertInPlaceToMatrix(rows, columns);
         return(new Cpu3DTensor(new[] { matrix }));
     }
 }