// File: /workspace/github_cpp_makefile_star2_O3/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 0x1f44e
movl $0x32, 0x30(%rbx)
xorl %ebp, %ebp
movq 0x17775(%rip), %r14     # 0x36fd8
leaq 0xb1d9(%rip), %r15      # 0x2aa43
leaq 0xb1ec(%rip), %r12      # 0x2aa5d
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 0x1fa80
incl %ebp
cmpl 0x30(%rbx), %ebp
jl 0x1f871
leaq 0xb176(%rip), %rsi      # 0x2aa5f
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 0x1f992
leaq 0xb12d(%rip), %r12      # 0x2aa6a
movsd (%rbp), %xmm0
movq 0x1768f(%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 0x1f93d
leaq 0xb130(%rip), %rsi      # 0x2aac9
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 0x1fa46
movq 0x175eb(%rip), %r14     # 0x36fd8
leaq 0xb55e(%rip), %r15      # 0x2af52
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 0x1f9f4
movq 0x18(%rbx), %rdi
movq (%rdi), %rax
callq *0x120(%rax)
movq (%rbx), %r14
movq 0x8(%rbx), %rbx
cmpq %rbx, %r14
je 0x1fa71
movq (%r14), %rdi
movq (%rdi), %rax
callq *0x120(%rax)
addq $0x8, %r14
jmp 0x1fa5a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq