// File: /workspace/github_cpp_makefile_star2_O1/xbai0624[P]dnn/src/Network.cpp
// Function: Network::Train()
void Network::Train()
{
    // construct layers
    TrainingType training_type = TrainingType::NewTraining;
    ConstructLayers(training_type);

    __numberOfEpoch = 50; // test QQQQQQQQQQQQQQQQQQQQQQQQQQQQ
    for(int i=0;i<__numberOfEpoch;i++)
    {
        std::cout<<"[------]Number of epoch: "<<i<<"/"<<__numberOfEpoch<<endl;
        UpdateEpoch();
    }

    // check accuracy track of training
    cout<<"accuracy: "<<endl;
    std::vector<double> & accuracy = __outputLayer->GetAccuracyForBatches();
    for(auto &i: accuracy)
        cout<<i<<",   "<<endl;

    // check cost track of training
    cout<<"cost: "<<endl;
    std::vector<double> &cost = __outputLayer->GetCostForBatches();
    for(auto &i: cost)
        cout<<i<<", "<<endl;

    // after finished training, save all trained weights and bias
    __inputLayer->SaveTrainedWeightsAndBias();
    for(auto &i: __middleAndOutputLayers)
        i->SaveTrainedWeightsAndBias();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x1f52e
movl $0x32, 0x30(%rbx)
xorl %ebp, %ebp
movq 0x1769d(%rip), %r14     # 0x36fd8
leaq 0xb141(%rip), %r15      # 0x2aa83
leaq 0xb154(%rip), %r12      # 0x2aa9d
movl $0x19, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x4280
movq %r14, %rdi
movl %ebp, %esi
callq 0x43c0
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x4280
movl 0x30(%rbx), %esi
movq %r13, %rdi
callq 0x43c0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r13, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
movq %rbx, %rdi
callq 0x1fb58
incl %ebp
cmpl 0x30(%rbx), %ebp
jl 0x1f949
leaq 0xb0de(%rip), %rsi      # 0x2aa9f
movl $0xa, %edx
movq %r14, %rdi
callq 0x4280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
movq 0x20(%rbx), %rdi
movq (%rdi), %rax
callq *0x2d8(%rax)
movq (%rax), %rbp
movq 0x8(%rax), %r15
cmpq %r15, %rbp
je 0x1fa6a
leaq 0xb095(%rip), %r12      # 0x2aaaa
movsd (%rbp), %xmm0
movq 0x175b7(%rip), %rdi     # 0x36fd8
callq 0x4340
movq %rax, %r13
movl $0x4, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x4280
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r13, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
addq $0x8, %rbp
cmpq %r15, %rbp
jne 0x1fa15
leaq 0xb098(%rip), %rsi      # 0x2ab09
movl $0x6, %edx
movq %r14, %rdi
callq 0x4280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
movq 0x20(%rbx), %rdi
movq (%rdi), %rax
callq *0x2e0(%rax)
movq (%rax), %r13
movq 0x8(%rax), %rbp
cmpq %rbp, %r13
je 0x1fb1e
movq 0x17513(%rip), %r14     # 0x36fd8
leaq 0xb4c6(%rip), %r15      # 0x2af92
movsd (%r13), %xmm0
movq %r14, %rdi
callq 0x4340
movq %rax, %r12
movl $0x2, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x4280
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r12, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
addq $0x8, %r13
cmpq %rbp, %r13
jne 0x1facc
movq 0x18(%rbx), %rdi
movq (%rdi), %rax
callq *0x120(%rax)
movq (%rbx), %r14
movq 0x8(%rbx), %rbx
cmpq %rbx, %r14
je 0x1fb49
movq (%r14), %rdi
movq (%rdi), %rax
callq *0x120(%rax)
addq $0x8, %r14
jmp 0x1fb32
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq