-
Notifications
You must be signed in to change notification settings - Fork 1
/
Random_Kernel_Convolution.cs
49 lines (42 loc) · 1.48 KB
/
Random_Kernel_Convolution.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LeNet5
{
class Random_Kernel
{
public static List<double[]> GenerateKernel(int Width,int Height,int Amount)
{
var list = new List<double[]>();
var rdm = new Random();
int i = 0;
while (i < Amount)
{
double[] arr = new double[Width * Height];
for (int j = 0; j < arr.Length; j++)
{
// arr[j] =rdm.Next(-1,1);
arr[j]= (rdm.NextDouble() - 0.5) * (4.8 / (Width*Height));
}
list.Add(arr);
// Console.WriteLine($"kernel:{arr[0]},{arr[1]},{arr[2]},{arr[5]}");
i++;
}
return list;
}
public static double[] GenerateKernel(int Width, int Height)
{
var rdm = new Random();
double[] arr = new double[Width * Height];
for (int j = 0; j < arr.Length; j++)
{
// arr[j] =rdm.Next(-1,1);
arr[j] = (rdm.NextDouble() - 0.5) * (4.8 / (Width * Height));
}
// Console.WriteLine($"kernel:{arr[0]},{arr[1]},{arr[2]},{arr[5]}");
return arr;
}
}
}