// File: 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:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq 0x80(%rsp), %rdi
movq %rdi, (%rsp)
movl $0x0, 0x7c(%rsp)
movl 0x7c(%rsp), %esi
callq 0x452d0
movq (%rsp), %rax
movl $0x32, 0x30(%rax)
movl $0x0, 0x78(%rsp)
movq (%rsp), %rcx
movl 0x78(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0x45dde
movq 0x25255(%rip), %rdi     # 0x6afd8
leaq 0xfb5a(%rip), %rsi      # 0x558e4
callq 0x4230
movq %rax, %rdi
movl 0x78(%rsp), %esi
callq 0x43e0
movq %rax, %rdi
leaq 0xfb59(%rip), %rsi      # 0x558fe
callq 0x4230
movq %rax, %rdi
movq (%rsp), %rax
movl 0x30(%rax), %esi
callq 0x43e0
movq %rax, %rdi
movq 0x251ed(%rip), %rsi     # 0x6afb0
callq 0x4260
movq (%rsp), %rdi
callq 0x45ff0
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x45d6f
movq 0x251f3(%rip), %rdi     # 0x6afd8
leaq 0xfb14(%rip), %rsi      # 0x55900
callq 0x4230
movq %rax, %rdi
movq 0x251b5(%rip), %rsi     # 0x6afb0
callq 0x4260
movq (%rsp), %rax
movq 0x20(%rax), %rdi
movq (%rdi), %rax
callq *0x2d8(%rax)
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
callq 0x21d50
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rdi
callq 0x21d80
movq %rax, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x21db0
testb $0x1, %al
jne 0x45e53
jmp 0x45ea1
leaq 0x60(%rsp), %rdi
callq 0x21df0
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movsd (%rax), %xmm0
movq 0x25166(%rip), %rdi     # 0x6afd8
callq 0x4440
movq %rax, %rdi
leaq 0xfa8a(%rip), %rsi      # 0x5590b
callq 0x4230
movq %rax, %rdi
movq 0x25120(%rip), %rsi     # 0x6afb0
callq 0x4260
leaq 0x60(%rsp), %rdi
callq 0x21e00
jmp 0x45e3e
movq 0x25130(%rip), %rdi     # 0x6afd8
leaq 0xfabb(%rip), %rsi      # 0x5596a
callq 0x4230
movq %rax, %rdi
movq 0x250f2(%rip), %rsi     # 0x6afb0
callq 0x4260
movq (%rsp), %rax
movq 0x20(%rax), %rdi
movq (%rdi), %rax
callq *0x2e0(%rax)
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
callq 0x21d50
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rdi
callq 0x21d80
movq %rax, 0x30(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x21db0
testb $0x1, %al
jne 0x45f16
jmp 0x45f64
leaq 0x38(%rsp), %rdi
callq 0x21df0
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movsd (%rax), %xmm0
movq 0x250a3(%rip), %rdi     # 0x6afd8
callq 0x4440
movq %rax, %rdi
leaq 0xfe8e(%rip), %rsi      # 0x55dd2
callq 0x4230
movq %rax, %rdi
movq 0x2505d(%rip), %rsi     # 0x6afb0
callq 0x4260
leaq 0x38(%rsp), %rdi
callq 0x21e00
jmp 0x45f01
movq (%rsp), %rax
movq 0x18(%rax), %rdi
movq (%rdi), %rax
callq *0x120(%rax)
movq (%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdi
callq 0x469a0
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x469d0
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x46a00
testb $0x1, %al
jne 0x45fb1
jmp 0x45fdd
leaq 0x18(%rsp), %rdi
callq 0x46a40
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq (%rdi), %rax
callq *0x120(%rax)
leaq 0x18(%rsp), %rdi
callq 0x46a50
jmp 0x45f9c
addq $0x88, %rsp
retq
nopw %cs:(%rax,%rax)