@@ -36,17 +36,34 @@ public class DigitRecognitionCNN : IExample
36
36
37
37
public string Name => "MNIST CNN" ;
38
38
39
- const int img_h = 28 ;
40
- const int img_w = 28 ;
39
+ string logs_path = "logs" ;
40
+
41
+ const int img_h = 28 , img_w = 28 ; // MNIST images are 28x28
41
42
int img_size_flat = img_h * img_w ; // 784, the total number of pixels
42
43
int n_classes = 10 ; // Number of classes, one class per digit
44
+ int n_channels = 1 ;
45
+
43
46
// Hyper-parameters
44
47
int epochs = 10 ;
45
48
int batch_size = 100 ;
46
49
float learning_rate = 0.001f ;
47
- int h1 = 200 ; // number of nodes in the 1st hidden layer
48
50
Datasets < DataSetMnist > mnist ;
49
51
52
+ // Network configuration
53
+ // 1st Convolutional Layer
54
+ int filter_size1 = 5 ; // Convolution filters are 5 x 5 pixels.
55
+ int num_filters1 = 16 ; // There are 16 of these filters.
56
+ int stride1 = 1 ; // The stride of the sliding window
57
+
58
+ // 2nd Convolutional Layer
59
+ int filter_size2 = 5 ; // Convolution filters are 5 x 5 pixels.
60
+ int num_filters2 = 32 ; // There are 32 of these filters.
61
+ int stride2 = 1 ; // The stride of the sliding window
62
+
63
+ // Fully-connected layer.
64
+ int h1 = 128 ; // Number of neurons in fully-connected layer.
65
+
66
+
50
67
Tensor x , y ;
51
68
Tensor loss , accuracy ;
52
69
Operation optimizer ;
@@ -123,6 +140,9 @@ private Tensor fc_layer(Tensor x, int num_units, string name, bool use_relu = tr
123
140
public void PrepareData ( )
124
141
{
125
142
mnist = MNIST . read_data_sets ( "mnist" , one_hot : true ) ;
143
+ print ( "Size of:" ) ;
144
+ print ( $ "- Training-set:\t \t { len ( mnist . train . data ) } ") ;
145
+ print ( $ "- Validation-set:\t { len ( mnist . validation . data ) } ") ;
126
146
}
127
147
128
148
public void Train ( Session sess )
0 commit comments