11 using namespace shark;
13 int main(
int argc,
char **argv)
16 cerr <<
"usage: " << argv[0] <<
" path/to/mnist_subset.libsvm" << endl;
19 std::size_t hidden1 = 200;
20 std::size_t hidden2 = 100;
21 std::size_t iterations = 10000;
22 double regularisation = 0.01;
28 for(std::size_t i = 0; i != numElems; ++i){
29 for(std::size_t j = 0; j != 784; ++j){
30 if(data.
element(i).input(j) > 0.5){
43 DenseLayer encoder1(inputs,hidden1);
44 DenseLayer encoder2(encoder1.outputShape(),hidden2);
45 auto encoder = encoder1 >> encoder2;
48 DenseLayer decoder1(encoder2.outputShape(), encoder2.inputShape());
49 DenseLayer decoder2(encoder1.outputShape(), encoder1.inputShape());
50 auto decoder = decoder1 >> decoder2;
53 auto autoencoder = encoder >> decoder;
56 autoencoder.enableModelOptimization(0,
false);
67 optimizer.
init(error);
68 std::cout<<
"Optimizing model "<<std::endl;
69 for(std::size_t i = 0; i != iterations; ++i){
70 optimizer.
step(error);