// File: /workspace/github_cpp_makefile_star2_O3/btbujiangjun[P]abcdl/example/fnn.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/fnn.model";

    abcdl::fnn::FNN fnn;
    fnn.set_alpha(0.1);
	fnn.set_batch_size(64);

    std::vector<abcdl::fnn::Layer*> layers;
    layers.push_back(new abcdl::fnn::InputLayer(784));
    //layers.push_back(new abcdl::fnn::FullConnLayer(784, 30, new abcdl::framework::SigmoidActivateFunc()));
    layers.push_back(new abcdl::fnn::FullConnLayer(784, 32, new abcdl::framework::ReluActivateFunc()));
    layers.push_back(new abcdl::fnn::OutputLayer(32, 10, new abcdl::framework::SigmoidActivateFunc(), new abcdl::framework::CrossEntropyCost()));
    fnn.set_layers(layers);

    const int train_size = -1;
    const int test_size = -1;
    
    //abcdl::utils::FashionMnistReader<real> helper("data");
    abcdl::utils::MnistReader<real> helper("data");
    abcdl::algebra::Mat train_data;
    helper.read_train_image(&train_data, train_size);
    abcdl::algebra::Mat train_label;
    helper.read_train_vec_label(&train_label, train_size);

    abcdl::algebra::Mat test_data;
    helper.read_test_image(&test_data, test_size);
    abcdl::algebra::Mat test_label;
    helper.read_test_vec_label(&test_label, test_size);
    real loss = 0;
	int epoch = 100;
    for(int i = 1; i <= epoch; i++){
		printf("Epoch:[%d/%d]\n", i, epoch);
        fnn.train(train_data, train_label);
        fnn.evaluate(test_data, test_label, &loss);
        fnn.write_model(path);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rsi, %rbx
movl %edi, %ebp
xorl %edi, %edi
callq 0x38764
movl %ebp, %edi
movq %rbx, %rsi
callq 0x38300
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x3033d(%rip), %rsi     # 0x3a0b0
leaq 0x30346(%rip), %rdx     # 0x3a0c0
leaq 0x60(%rsp), %rdi
callq 0x145ac
leaq 0x148(%rsp), %rdi
callq 0x103dc
movl $0x3dcccccd, 0x148(%rsp) # imm = 0x3DCCCCCD
movq $0x40, 0x150(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x168, %edi            # imm = 0x168
callq 0x9370
movq %rax, %r14
movl $0x310, %esi            # imm = 0x310
movl $0x310, %edx            # imm = 0x310
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x11022
leaq 0x4c1af(%rip), %rax     # 0x55f90
movq %rax, (%r14)
movq %r14, 0xa8(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9e03
movq %r14, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x9e15
leaq 0x10(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x14642
movl $0x170, %edi            # imm = 0x170
callq 0x9370
movq %rax, %r14
movl $0x18, %edi
callq 0x9370
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x4c22c(%rip), %r12     # 0x56070
movq %r12, (%rax)
movq %rax, %rdi
addq $0x8, %rdi
callq 0xbb7c
leaq 0x4c1be(%rip), %rax     # 0x56018
movq %rax, (%r15)
leaq 0x38(%rsp), %r8
movl $0x0, (%r8)
leaq 0x80(%rsp), %rbx
movl $0x3f000000, (%rbx)     # imm = 0x3F000000
movl $0x310, %esi            # imm = 0x310
movl $0x20, %edx
movq %r14, %rdi
movq %r15, %rcx
movq %rbx, %r9
callq 0x10468
movq %r14, 0xa8(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9eae
movq %r14, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x9ec0
leaq 0x10(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x14642
movl $0x1a0, %edi            # imm = 0x1A0
callq 0x9370
movq %rax, %r14
movl $0x18, %edi
callq 0x9370
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %r12, (%rax)
movq %rax, %rdi
addq $0x8, %rdi
callq 0xbb7c
leaq 0x4c1a2(%rip), %rax     # 0x560a0
movq %rax, (%r15)
movl $0x18, %edi
callq 0x9370
movq %rax, %r12
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x4c215(%rip), %rax     # 0x56138
movq %rax, (%r12)
movq %r12, %rdi
addq $0x8, %rdi
callq 0xbb7c
leaq 0x4c1ae(%rip), %rax     # 0x560e8
movq %rax, (%r12)
leaq 0x38(%rsp), %r9
movl $0x0, (%r9)
movl $0x3f000000, 0x80(%rsp) # imm = 0x3F000000
movq %rbx, (%rsp)
movl $0x20, %esi
movl $0xa, %edx
movq %r14, %rdi
movq %r15, %rcx
movq %r12, %r8
callq 0x10518
movq %r14, 0xa8(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9f90
movq %r14, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x9fa2
leaq 0x10(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x14642
leaq 0x148(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x105f4
leaq 0x48(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x300fd(%rip), %rsi     # 0x3a0c1
leaq 0x300fa(%rip), %rdx     # 0x3a0c5
leaq 0x38(%rsp), %rdi
callq 0x145ac
leaq 0xa8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x107aa
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x9ff6
callq 0x9350
leaq 0x38(%rsp), %rdi
callq 0x197e0
leaq 0xa8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
callq 0x1083a
leaq 0x80(%rsp), %rdi
callq 0x197e0
leaq 0xa8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movl $0xa, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x109ea
leaq 0x120(%rsp), %rdi
callq 0x197e0
leaq 0xa8(%rsp), %rdi
leaq 0x120(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
callq 0x10b80
leaq 0xf8(%rsp), %rdi
callq 0x197e0
leaq 0xa8(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
movl $0xa, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x10d30
leaq 0x34(%rsp), %rax
movl $0x0, (%rax)
movl $0x1, %ebp
leaq 0x148(%rsp), %r15
leaq 0x80(%rsp), %r13
leaq 0x120(%rsp), %rbx
leaq 0xf8(%rsp), %r14
leaq 0x60(%rsp), %r12
leaq 0x2fff0(%rip), %rdi     # 0x3a0c6
movl %ebp, %esi
movl $0x64, %edx
xorl %eax, %eax
callq 0x9060
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
movq %r13, %rdx
callq 0x15394
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
leaq 0x34(%rsp), %rcx
callq 0x15c44
movq %r15, %rdi
movq %r12, %rsi
callq 0x167dc
incl %ebp
cmpl $0x65, %ebp
jne 0xa0cf
leaq 0xf8(%rsp), %rdi
callq 0x19a36
leaq 0x120(%rsp), %rdi
callq 0x19a36
leaq 0x80(%rsp), %rdi
callq 0x19a36
leaq 0x38(%rsp), %rdi
callq 0x19a36
leaq 0x4c00f(%rip), %rax     # 0x56160
leaq 0xe0(%rsp), %rcx
movq %rax, -0x38(%rcx)
movq -0x10(%rcx), %rdi
cmpq %rcx, %rdi
je 0xa16b
callq 0x9350
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq 0x70(%rsp), %rbx
je 0xa186
callq 0x9350
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa195
callq 0x9350
leaq 0x148(%rsp), %rdi
callq 0x10efc
movq 0x60(%rsp), %rdi
cmpq %rbx, %rdi
je 0xa1b1
callq 0x9350
xorl %eax, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa223
jmp 0xa223
jmp 0xa235
jmp 0xa1cd
movq %rax, %rbx
jmp 0xa245
jmp 0xa1d4
movq %rax, %rbx
jmp 0xa252
jmp 0xa1db
movq %rax, %rbx
jmp 0xa25f
movq %rax, %rbx
jmp 0xa269
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
jne 0xa22e
jmp 0xa276
jmp 0xa223
jmp 0xa223
jmp 0xa228
movq %rax, %rbx
movq %r12, %rdi
jmp 0xa211
jmp 0xa20b
jmp 0xa223
jmp 0xa228
movq %rax, %rbx
movq %r15, %rdi
callq 0x9350
jmp 0xa22b
jmp 0xa228
jmp 0xa223
jmp 0xa228
movq %rax, %rbx
jmp 0xa292
movq %rax, %rbx
jmp 0xa276
movq %rax, %rbx
movq %r14, %rdi
callq 0x9350
jmp 0xa276
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x19a36
leaq 0x120(%rsp), %rdi
callq 0x19a36
leaq 0x80(%rsp), %rdi
callq 0x19a36
leaq 0x38(%rsp), %rdi
callq 0x19a36
leaq 0xa8(%rsp), %rdi
callq 0x10ec6
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa285
callq 0x9350
leaq 0x148(%rsp), %rdi
callq 0x10efc
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xa2a6
callq 0x9350
movq %rbx, %rdi
callq 0x95d0