// File: /workspace/github_cpp_makefile_star2_O1/btbujiangjun[P]abcdl/example/cnn.cpp
// Function: main
int main(int argc, char** argv){
    abcdl::utils::log::set_min_log_level(abcdl::utils::log::INFO);
    abcdl::utils::log::initialize_log(argc, argv);

    const std::string path = "./data/cnn.model";

    std::vector<abcdl::cnn::Layer*> layers;
    layers.push_back(new abcdl::cnn::InputLayer(28, 28));
    layers.push_back(new abcdl::cnn::ConvolutionLayer(3, 1, 5, new abcdl::framework::SigmoidActivateFunc()));
    layers.push_back(new abcdl::cnn::SubSamplingLayer(2, new abcdl::framework::MeanPooling()));
    layers.push_back(new abcdl::cnn::ConvolutionLayer(3, 1, 5, new abcdl::framework::SigmoidActivateFunc()));
//    layers.push_back(new abcdl::cnn::SubSamplingLayer(2, new abcdl::cnn::MeanPooling()));
    layers.push_back(new abcdl::cnn::OutputLayer(10, new abcdl::framework::SigmoidActivateFunc(), new abcdl::framework::CrossEntropyCost()));

    abcdl::cnn::CNN cnn;
    cnn.set_layers(layers);
	cnn.set_batch_size(1);
	cnn.set_alpha(0.1);

    //abcdl::utils::FashionMnistReader<real> helper("data");
    abcdl::utils::MnistReader<real> helper("data");
    const size_t train_size = 60000;
    const size_t test_size  = 10000;

    abcdl::algebra::MatSet train_data;
    helper.read_train_images(train_data, train_size, 30);

    abcdl::algebra::MatSet train_label;
    helper.read_train_vec_labels(train_label, train_size);

    abcdl::algebra::MatSet test_data;
    helper.read_test_images(test_data, test_size);

    abcdl::algebra::MatSet test_label;
    helper.read_test_vec_labels(test_label, test_size);

    cnn.train(train_data, train_label, test_data, test_label);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %rbx
movl %edi, %ebp
xorl %edi, %edi
callq 0x37384
movl %ebp, %edi
movq %rbx, %rsi
callq 0x36f30
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2f3e2(%rip), %rsi     # 0x380b8
leaq 0x2f3eb(%rip), %rdx     # 0x380c8
leaq 0xc0(%rsp), %rdi
callq 0x133ac
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movl $0xd0, %edi
callq 0x8320
movq %rax, %r14
movl $0x1c, %esi
movl $0x1c, %edx
movl $0x1, %ecx
movl $0x1, %r8d
movq %rax, %rdi
xorl %r9d, %r9d
callq 0xffb2
leaq 0x4b182(%rip), %rax     # 0x53eb0
movq %rax, (%r14)
movq %r14, 0x70(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x8d4d
movq %r14, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x8d5a
movq %rsp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1343c
movl $0xe8, %edi
callq 0x8320
movq %rax, %r14
movl $0x18, %edi
callq 0x8320
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x4b217(%rip), %r12     # 0x53fa0
movq %r12, (%rax)
movq %rax, %rdi
addq $0x8, %rdi
callq 0xac94
leaq 0x4b1a9(%rip), %rbp     # 0x53f48
movq %rbp, (%r15)
movl $0x1, %ecx
movl $0x5, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0x3, %r9d
callq 0xffb2
leaq 0x4be32(%rip), %r13     # 0x54bf8
addq $0x10, %r13
movq %r13, (%r14)
movq $0x3, 0xd8(%r14)
movq $0x1, 0xd0(%r14)
movq %r15, 0xe0(%r14)
movq %r14, 0x70(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x8e06
movq %r14, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x8e13
movq %rsp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1343c
movl $0xe0, %edi
callq 0x8320
movq %rax, %r14
movl $0x8, %edi
callq 0x8320
movq %rax, %rbx
leaq 0x4be64(%rip), %rax     # 0x54c98
addq $0x10, %rax
movq %rax, (%rbx)
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x2, %r9d
callq 0xffb2
leaq 0x4bd4f(%rip), %rax     # 0x54ba8
addq $0x10, %rax
movq %rax, (%r14)
movq $0x2, 0xd0(%r14)
movq %rbx, 0xd8(%r14)
movq %r14, 0x70(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x8e8e
movq %r14, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x8e9b
movq %rsp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1343c
movl $0xe8, %edi
callq 0x8320
movq %rax, %r14
movl $0x18, %edi
callq 0x8320
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %r12, (%rax)
movq %rax, %rdi
addq $0x8, %rdi
callq 0xac94
movq %rbp, (%r15)
movl $0x1, %ecx
movl $0x5, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0x3, %r9d
callq 0xffb2
movq %r13, (%r14)
movq $0x3, 0xd8(%r14)
movq $0x1, 0xd0(%r14)
movq %r15, 0xe0(%r14)
movq %r14, 0x70(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x8f2e
movq %r14, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x8f3b
movq %rsp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1343c
movl $0x138, %edi            # imm = 0x138
callq 0x8320
movq %rax, %r14
movl $0x18, %edi
callq 0x8320
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %r12, (%rax)
movq %rax, %rdi
addq $0x8, %rdi
callq 0xac94
movq %rbp, (%r15)
movl $0x18, %edi
callq 0x8320
movq %rax, %r12
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x4b089(%rip), %rax     # 0x54020
movq %rax, (%r12)
movq %r12, %rdi
addq $0x8, %rdi
callq 0xac94
leaq 0x4b022(%rip), %rax     # 0x53fd0
movq %rax, (%r12)
movl $0xa, %esi
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0xf70a
movq %r14, 0x70(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x8fe1
movq %r14, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x8fee
movq %rsp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1343c
movq $0x32, 0x40(%rsp)
movq $0x1, 0x48(%rsp)
movl $0x3dcccccd, 0x50(%rsp) # imm = 0x3DCCCCCD
xorps %xmm0, %xmm0
movups %xmm0, 0x58(%rsp)
movq $0x0, 0x68(%rsp)
leaq 0x140(%rsp), %rdi
movq %rsp, %rsi
callq 0xf794
leaq 0x40(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x159dc
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x904d
callq 0x8300
movq $0x1, 0x48(%rsp)
movl $0x3dcccccd, 0x50(%rsp) # imm = 0x3DCCCCCD
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x2f05b(%rip), %rsi     # 0x380c9
leaq 0x2f058(%rip), %rdx     # 0x380cd
leaq 0x20(%rsp), %rdi
callq 0x133ac
leaq 0x70(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xf814
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x909d
callq 0x8300
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x70(%rsp), %rdi
movl $0x1e, %ecx
movl $0xea60, %edx           # imm = 0xEA60
callq 0xf8a4
leaq 0x120(%rsp), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x70(%rsp), %rdi
movl $0xa, %ecx
movl $0xea60, %edx           # imm = 0xEA60
callq 0xfa54
xorps %xmm0, %xmm0
leaq 0x100(%rsp), %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x70(%rsp), %rdi
movl $0x2710, %edx           # imm = 0x2710
xorl %ecx, %ecx
callq 0xfbea
leaq 0xe0(%rsp), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x70(%rsp), %rdi
movl $0xa, %ecx
movl $0x2710, %edx           # imm = 0x2710
callq 0xfd9a
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x120(%rsp), %rdx
leaq 0x100(%rsp), %rcx
leaq 0xe0(%rsp), %r8
callq 0x15afc
leaq 0xe0(%rsp), %rdi
callq 0x105d4
leaq 0x100(%rsp), %rdi
callq 0x105d4
leaq 0x120(%rsp), %rdi
callq 0x105d4
leaq 0x20(%rsp), %rdi
callq 0x105d4
leaq 0x4aeaa(%rip), %rax     # 0x54048
leaq 0xa8(%rsp), %rcx
movq %rax, -0x38(%rcx)
movq -0x10(%rcx), %rdi
cmpq %rcx, %rdi
je 0x91b8
callq 0x8300
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x91ce
callq 0x8300
leaq 0x40(%rsp), %rdi
callq 0xff66
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x91e6
callq 0x8300
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x9200
callq 0x8300
xorl %eax, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x928e
movq %rax, %rbx
jmp 0x929b
movq %rax, %rbx
jmp 0x92a8
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
jne 0x924a
jmp 0x92bc
jmp 0x9251
movq %rax, %rbx
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x92bc
callq 0x8300
jmp 0x92bc
movq %rax, %rbx
jmp 0x92bc
movq %rax, %rbx
movq %r12, %rdi
jmp 0x9268
jmp 0x9262
jmp 0x9262
movq %rax, %rbx
movq %r15, %rdi
callq 0x8300
jmp 0x92d1
jmp 0x92ce
jmp 0x9279
jmp 0x9279
jmp 0x9279
jmp 0x9279
movq %rax, %rbx
jmp 0x92d9
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x105d4
leaq 0x100(%rsp), %rdi
callq 0x105d4
leaq 0x120(%rsp), %rdi
callq 0x105d4
leaq 0x20(%rsp), %rdi
callq 0x105d4
leaq 0x70(%rsp), %rdi
callq 0xff30
leaq 0x40(%rsp), %rdi
callq 0xff66
jmp 0x92d9
jmp 0x92ce
jmp 0x92ce
jmp 0x92ce
movq %rax, %rbx
movq %r14, %rdi
callq 0x8300
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x92e7
callq 0x8300
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x9301
callq 0x8300
movq %rbx, %rdi
callq 0x8500
nop