Exemple #1
0
        private void Forward(TensorOld input, int sampleIndex, int filterIndex)
        {
            Parallel.For(0, outRows, row =>
            {
                var startRow = row * RowStride;
                Parallel.For(0, outColumns, col =>
                {
                    var startCol = col * ColumnStride;
                    var sum      = 0d;

                    for (int i = 0; i < FilterRows; i++)
                    {
                        var inputRow = startRow + i;
                        for (int j = 0; j < FilterColumns; j++)
                        {
                            var inputCol = startCol + j;

                            for (int k = 0; k < channels; k++)
                            {
                                sum += PaddingInput[sampleIndex, k, inputRow, inputCol] * Filters[filterIndex, k, i, j];
                            }
                        }
                    }
                    ForwardOutput[sampleIndex, filterIndex, row, col] = sum + Bias.GetRawValues()[filterIndex];
                });
            });
        }
Exemple #2
0
 public void SetBias(TensorOld bias)
 {
     if (Bias == null)
     {
         foreach (var item in mirrorList)
         {
             item.Bias = bias;
         }
     }
     TensorOld.CheckShape(Bias, bias);
     Array.Copy(bias.GetRawValues(), 0, Bias.GetRawValues(), 0, Bias.ElementCount);
 }