// File: /workspace/github_cpp_makefile_star2_O2/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 $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, %rbx
movl %edi, %ebp
xorl %edi, %edi
callq 0x2edc6
movl %ebp, %edi
movq %rbx, %rsi
callq 0x2ead0
leaq 0x265c6(%rip), %rsi     # 0x300b0
leaq 0x118(%rsp), %rdi
leaq 0x138(%rsp), %rdx
callq 0x9120
leaq 0x138(%rsp), %rdi
callq 0xfc2c
movl $0x3dcccccd, 0x138(%rsp) # imm = 0x3DCCCCCD
movq $0x40, 0x140(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movl $0x168, %edi            # imm = 0x168
callq 0x9380
movq %rax, %r14
movl $0x310, %esi            # imm = 0x310
movq %rax, %rdi
callq 0xfcca
leaq 0xc8(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x134be
movl $0x170, %edi            # imm = 0x170
callq 0x9380
movq %rax, %r14
pushq $0x18
popq %rdi
callq 0x9380
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x434e6(%rip), %r12     # 0x4d070
movq %r12, (%rax)
movq %rax, %rdi
addq $0x8, %rdi
callq 0xb6e2
leaq 0x28(%rsp), %r8
andl $0x0, (%r8)
leaq 0x4346f(%rip), %rax     # 0x4d018
movq %rax, (%r15)
leaq 0x50(%rsp), %rbx
movl $0x3f000000, (%rbx)     # imm = 0x3F000000
pushq $0x20
popq %rdx
movl $0x310, %esi            # imm = 0x310
movq %r14, %rdi
movq %r15, %rcx
movq %rbx, %r9
callq 0xfce4
leaq 0xc8(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x134be
movl $0x1a0, %edi            # imm = 0x1A0
callq 0x9380
movq %rax, %r14
pushq $0x18
popq %rdi
callq 0x9380
movq %rax, %r15
xorps %xmm0, %xmm0
andq $0x0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %r12, (%rax)
movq %rax, %rdi
addq $0x8, %rdi
callq 0xb6e2
leaq 0x43485(%rip), %rax     # 0x4d0a0
movq %rax, (%r15)
pushq $0x18
popq %rdi
callq 0x9380
movq %rax, %r12
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x434fd(%rip), %rax     # 0x4d138
movq %rax, (%r12)
movq %r12, %rdi
addq $0x8, %rdi
callq 0xb6e2
leaq 0x43496(%rip), %rax     # 0x4d0e8
movq %rax, (%r12)
leaq 0x28(%rsp), %r9
andl $0x0, (%r9)
movl $0x3f000000, 0x50(%rsp) # imm = 0x3F000000
movq %rbx, (%rsp)
pushq $0x20
popq %rsi
pushq $0xa
popq %rdx
movq %r14, %rdi
movq %r15, %rcx
movq %r12, %r8
callq 0xfd90
leaq 0xc8(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x134be
leaq 0x138(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xfe6a
leaq 0x26414(%rip), %rsi     # 0x300c1
leaq 0x28(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x9120
leaq 0xc8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x1000c
leaq 0x28(%rsp), %rdi
callq 0x9160
leaq 0x28(%rsp), %rdi
callq 0x17dac
leaq 0xc8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
pushq $-0x1
popq %rdx
xorl %ecx, %ecx
callq 0x10088
leaq 0x50(%rsp), %rdi
callq 0x17dac
leaq 0xc8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
pushq $-0x1
popq %rdx
pushq $0xa
popq %rcx
callq 0x10152
leaq 0xa0(%rsp), %rdi
callq 0x17dac
leaq 0xc8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
pushq $-0x1
popq %rdx
xorl %ecx, %ecx
callq 0x10220
leaq 0x78(%rsp), %rdi
callq 0x17dac
leaq 0xc8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
pushq $-0x1
popq %rdx
pushq $0xa
popq %rcx
callq 0x102ea
leaq 0xc(%rsp), %rax
andl $0x0, (%rax)
pushq $0x1
popq %rbp
leaq 0x138(%rsp), %r12
leaq 0x50(%rsp), %rbx
leaq 0xa0(%rsp), %r14
leaq 0x78(%rsp), %r15
leaq 0x118(%rsp), %r13
cmpl $0x65, %ebp
je 0x9ddb
leaq 0x26329(%rip), %rdi     # 0x300c6
movl %ebp, %esi
pushq $0x64
popq %rdx
xorl %eax, %eax
callq 0x9050
movq %r12, %rdi
leaq 0x28(%rsp), %rsi
movq %rbx, %rdx
callq 0x14158
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
leaq 0xc(%rsp), %rcx
callq 0x14876
movq %r12, %rdi
movq %r13, %rsi
callq 0x152aa
incl %ebp
jmp 0x9d91
leaq 0x78(%rsp), %rdi
callq 0x17fd6
leaq 0xa0(%rsp), %rdi
callq 0x17fd6
leaq 0x50(%rsp), %rdi
callq 0x17fd6
leaq 0x28(%rsp), %rdi
callq 0x17fd6
leaq 0xc8(%rsp), %rdi
callq 0x103b8
leaq 0x10(%rsp), %rdi
callq 0x134b0
leaq 0x138(%rsp), %rdi
callq 0x103dc
leaq 0x118(%rsp), %rdi
callq 0x9160
xorl %eax, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9eb8
jmp 0x9e4f
movq %rax, %rbx
jmp 0x9ec5
jmp 0x9e56
movq %rax, %rbx
jmp 0x9ed2
jmp 0x9e5d
movq %rax, %rbx
jmp 0x9edc
movq %rax, %rbx
jmp 0x9ee6
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x9160
jmp 0x9ef3
jmp 0x9eb3
jmp 0x9eb3
jmp 0x9eb3
jmp 0x9ea6
movq %rax, %rbx
movq %r12, %rdi
jmp 0x9e94
jmp 0x9e8e
jmp 0x9eb3
jmp 0x9eb3
jmp 0x9ea6
movq %rax, %rbx
movq %r15, %rdi
callq 0x9360
jmp 0x9ea9
jmp 0x9ea6
jmp 0x9eb3
jmp 0x9ea6
movq %rax, %rbx
jmp 0x9f0a
movq %rax, %rbx
movq %r14, %rdi
callq 0x9360
jmp 0x9ef3
movq %rax, %rbx
jmp 0x9ef3
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x17fd6
leaq 0xa0(%rsp), %rdi
callq 0x17fd6
leaq 0x50(%rsp), %rdi
callq 0x17fd6
leaq 0x28(%rsp), %rdi
callq 0x17fd6
leaq 0xc8(%rsp), %rdi
callq 0x103b8
leaq 0x10(%rsp), %rdi
callq 0x134b0
leaq 0x138(%rsp), %rdi
callq 0x103dc
leaq 0x118(%rsp), %rdi
callq 0x9160
movq %rbx, %rdi
callq 0x95e0
nop