// File: /workspace/github_cpp_makefile_star2_O1/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 0x388fc
movl %ebp, %edi
movq %rbx, %rsi
callq 0x384a8
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x3031d(%rip), %rsi     # 0x3a0b0
leaq 0x30326(%rip), %rdx     # 0x3a0c0
leaq 0x60(%rsp), %rdi
callq 0x148b8
leaq 0x148(%rsp), %rdi
callq 0x106f2
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 0x1135a
leaq 0x4c18f(%rip), %rax     # 0x55f90
movq %rax, (%r14)
movq %r14, 0xa8(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9e23
movq %r14, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x9e35
leaq 0x10(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x14948
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 0x4c20c(%rip), %r12     # 0x56070
movq %r12, (%rax)
movq %rax, %rdi
addq $0x8, %rdi
callq 0xbc7c
leaq 0x4c19e(%rip), %rax     # 0x56018
movq %rax, (%r15)
leaq 0x38(%rsp), %r8
movl $0x0, (%r8)
leaq 0x80(%rsp), %rbx
movl $0x3f000000, (%rbx)     # imm = 0x3F000000
movb $0x1, %bpl
movl $0x310, %esi            # imm = 0x310
movl $0x20, %edx
movq %r14, %rdi
movq %r15, %rcx
movq %rbx, %r9
callq 0x1079a
movq %r14, 0xa8(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9ed1
movq %r14, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x9ee5
xorl %ebp, %ebp
leaq 0x10(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x14948
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 0xbc7c
leaq 0x4c17d(%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 0x4c1f0(%rip), %rax     # 0x56138
movq %rax, (%r12)
movq %r12, %rdi
addq $0x8, %rdi
callq 0xbc7c
leaq 0x4c189(%rip), %rax     # 0x560e8
movq %rax, (%r12)
leaq 0x38(%rsp), %r9
movl $0x0, (%r9)
movl $0x3f000000, 0x80(%rsp) # imm = 0x3F000000
movb $0x1, %bpl
movq %rbx, (%rsp)
movl $0x20, %esi
movl $0xa, %edx
movq %r14, %rdi
movq %r15, %rcx
movq %r12, %r8
callq 0x1084a
movq %r14, 0xa8(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9fb8
movq %r14, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x9fcc
xorl %ebp, %ebp
leaq 0x10(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x14948
leaq 0x148(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x10926
leaq 0x48(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x300d3(%rip), %rsi     # 0x3a0c1
leaq 0x300d0(%rip), %rdx     # 0x3a0c5
leaq 0x38(%rsp), %rdi
callq 0x148b8
leaq 0xa8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x10ae4
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0xa020
callq 0x9350
leaq 0x38(%rsp), %rdi
callq 0x19a38
leaq 0xa8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
callq 0x10b74
leaq 0x80(%rsp), %rdi
callq 0x19a38
leaq 0xa8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movl $0xa, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x10d24
leaq 0x120(%rsp), %rdi
callq 0x19a38
leaq 0xa8(%rsp), %rdi
leaq 0x120(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
callq 0x10eba
leaq 0xf8(%rsp), %rdi
callq 0x19a38
leaq 0xa8(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
movl $0xa, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x1106a
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 0x2ffc6(%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 0x15690
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
leaq 0x34(%rsp), %rcx
callq 0x15f08
movq %r15, %rdi
movq %r12, %rsi
callq 0x16a6c
incl %ebp
cmpl $0x65, %ebp
jne 0xa0f9
leaq 0xf8(%rsp), %rdi
callq 0x19c8e
leaq 0x120(%rsp), %rdi
callq 0x19c8e
leaq 0x80(%rsp), %rdi
callq 0x19c8e
leaq 0x38(%rsp), %rdi
callq 0x19c8e
leaq 0x4bfe5(%rip), %rax     # 0x56160
leaq 0xe0(%rsp), %rcx
movq %rax, -0x38(%rcx)
movq -0x10(%rcx), %rdi
cmpq %rcx, %rdi
je 0xa195
callq 0x9350
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq 0x70(%rsp), %rbx
je 0xa1b0
callq 0x9350
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa1bf
callq 0x9350
leaq 0x148(%rsp), %rdi
callq 0x11236
movq 0x60(%rsp), %rdi
cmpq %rbx, %rdi
je 0xa1db
callq 0x9350
xorl %eax, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa278
jmp 0xa1f6
movq %rax, %rbx
jmp 0xa288
jmp 0xa200
movq %rax, %rbx
jmp 0xa295
jmp 0xa20a
movq %rax, %rbx
jmp 0xa2a2
movq %rax, %rbx
jmp 0xa2ac
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
jne 0xa271
jmp 0xa2b9
jmp 0xa25e
jmp 0xa25e
movq %rax, %rbx
movq %r12, %rdi
jmp 0xa242
jmp 0xa23c
jmp 0xa25e
movq %rax, %rbx
movq %r15, %rdi
callq 0x9350
jmp 0xa266
jmp 0xa263
jmp 0xa25e
movq %rax, %rbx
jmp 0xa26e
movq %rax, %rbx
jmp 0xa2d5
jmp 0xa259
movq %rax, %rbx
jmp 0xa269
movq %rax, %rbx
jmp 0xa2b9
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0xa2b9
movq %r14, %rdi
callq 0x9350
jmp 0xa2b9
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x19c8e
leaq 0x120(%rsp), %rdi
callq 0x19c8e
leaq 0x80(%rsp), %rdi
callq 0x19c8e
leaq 0x38(%rsp), %rdi
callq 0x19c8e
leaq 0xa8(%rsp), %rdi
callq 0x11200
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa2c8
callq 0x9350
leaq 0x148(%rsp), %rdi
callq 0x11236
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xa2e9
callq 0x9350
movq %rbx, %rdi
callq 0x95d0
nop