@@ -36,17 +36,34 @@ public class DigitRecognitionCNN : IExample
3636
3737 public string Name => "MNIST CNN" ;
3838
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
4142 int img_size_flat = img_h * img_w ; // 784, the total number of pixels
4243 int n_classes = 10 ; // Number of classes, one class per digit
44+ int n_channels = 1 ;
45+
4346 // Hyper-parameters
4447 int epochs = 10 ;
4548 int batch_size = 100 ;
4649 float learning_rate = 0.001f ;
47- int h1 = 200 ; // number of nodes in the 1st hidden layer
4850 Datasets < DataSetMnist > mnist ;
4951
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+
5067 Tensor x , y ;
5168 Tensor loss , accuracy ;
5269 Operation optimizer ;
@@ -123,6 +140,9 @@ private Tensor fc_layer(Tensor x, int num_units, string name, bool use_relu = tr
123140 public void PrepareData ( )
124141 {
125142 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 ) } ") ;
126146 }
127147
128148 public void Train ( Session sess )
0 commit comments