|
@@ -8,27 +8,21 @@
|
|
|
using namespace Layer;
|
|
|
|
|
|
int main(int argc,char** argv){
|
|
|
- Network N;
|
|
|
+ //Test of convolution layer
|
|
|
size_t nf=4;
|
|
|
- ConvolutionLayer L1(1,28,28,5,5,nf);
|
|
|
- L1.init(0,1);
|
|
|
- ActivationLayer<Sigmoid> L2(nf*24*24);
|
|
|
- //Layer::Pooling L3(nf,24,24,2,2);
|
|
|
- FullConnectedLayer L4(nf*24*24,10);
|
|
|
- L4.init_standard();
|
|
|
- ActivationLayer<Sigmoid> L5(10);
|
|
|
- L1.name="[Convolutionnal]";
|
|
|
- L2.name="[Sigmoid of convolutionnal]";
|
|
|
- //L3.name="[Pooling]";
|
|
|
- L4.name="[Full connected]";
|
|
|
- L5.name="[Sigmoid of full]";
|
|
|
-
|
|
|
- N.push_layer(L1);
|
|
|
- N.push_layer(L2);
|
|
|
- // N.push_layer(&L3);
|
|
|
- N.push_layer(L4);
|
|
|
- N.push_layer(L5);
|
|
|
- N.is_done();
|
|
|
+ ConvolutionLayer L(1,28,28,5,5,nf);
|
|
|
Mnist dataset;
|
|
|
- N.train(&dataset,1,10,0.1);
|
|
|
+ size_t N=dataset.get_train_size();
|
|
|
+ clock_t c_start = clock();
|
|
|
+ auto t_start = chrono::high_resolution_clock::now();
|
|
|
+ for(int j=0;j<10;++j){
|
|
|
+ for(size_t i=0;i<N;++i){
|
|
|
+ pair<Vector,Vector> data=dataset.get_train(i);
|
|
|
+ Vector x=data.first;
|
|
|
+ L.feed_forward(x);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ auto t_end = chrono::high_resolution_clock::now();
|
|
|
+ cout<< "Duration: "<< chrono::duration<double, std::milli>(t_end-t_start).count()<<" ms\n";
|
|
|
+
|
|
|
}
|