diff --git a/src/test.cpp b/src/test.cpp index f14d40e..b20de9c 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -257,10 +257,111 @@ int main() // Test MNIST dataset. Tensor ** train_image=dataset::Read_MNIST_Train_Image("../dataset/train-images-idx3-ubyte"); Tensor ** train_label=dataset::Read_MNIST_Train_Label("../dataset/train-labels-idx1-ubyte"); - dataset::Visualize_Grayscale(*train_image[59999],cout); - cout<p[0]<p[0]<reshape({28*28,1}); + } + for (int j=0;j<10000;++j) + { + test_image[j]->reshape({28*28,1}); + } + + //Build Graph + + Variable & out = mynet(x); + Variable & loss = Graph::SoftmaxCrossEntropy(out,y); + + // Define an optimizer + int batch_size=100; + float learning_rate=0.1; + float weight_decay=5e-4; + SGDOptimizer myoptim(batch_size, learning_rate, weight_decay); + + + for (int epoch=0;epoch<1;++epoch) + { + for (int inner_loop=0; inner_loop<10000; ++inner_loop) + { + //Manual Assign tensor to x and y. + // Random SHUFLLE !!!!!!!!!!! + x.data=train_image[inner_loop]; + y.data=train_label[inner_loop]; + Graph::eval(loss); + if ((inner_loop+1) % batch_size ==0) + cout<p[0]<p[0])) + ++total_correct; + } + cout<<"Numbers of correctness: "<