// File: /workspace/github_cpp_makefile_star2_O3/theolepage[P]prophecy/src/model/model.hh
// Function: Model<float>::train(std::vector<Matrix<float>, std::allocator<Matrix<float>>>&, std::vector<Matrix<float>, std::allocator<Matrix<float>>>&, int, int)
void train(std::vector<Matrix<T>>& x,
                std::vector<Matrix<T>>& y,
                int epochs,
                int batch_size)
    {
        if (!compiled_)
            throw "Model has not been compiled.";

        for (int epoch = 0; epoch < epochs; epoch++)
        {
            // Determine batches
            int i = 0;
            int nb_batches = ceil(x.size() / batch_size);
            for (int batch = 0; batch < nb_batches; batch++)
            {
                // For each batch, compute delta weights and biases
                for (int k = 0; k < batch_size && i < static_cast<int>(x.size()); k++)
                {
                    layers_[0]->feedforward(x[i], true);
                    layers_[layers_.size() - 1]->backpropagation(&y[i]);
                    ++i;
                }

                // At the end of batch, update weights_ and biases_
                for (size_t l = 1; l < layers_.size(); l++)
                {
                    auto layer = std::dynamic_pointer_cast<HiddenLayer<T>>(layers_[l]);
                    layer->update(learning_rate_);
                }
            }
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, 0x40(%rsp)
cmpb $0x1, 0x8(%rdi)
jne 0x304a
testl %ecx, %ecx
jle 0x303b
movq %rsi, %r15
movq %rdi, %r12
movslq %r8d, %rax
movq %rax, 0x20(%rsp)
movl %eax, %ebp
negl %ebp
xorl %eax, %eax
movq %r8, 0x30(%rsp)
movl %ecx, 0x14(%rsp)
movq %rax, 0x28(%rsp)
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x5, %rax
xorl %edx, %edx
divq 0x20(%rsp)
movq %rax, 0x38(%rsp)
testl %eax, %eax
jle 0x3028
xorl %eax, %eax
movq $0x0, 0x8(%rsp)
movl %eax, 0x1c(%rsp)
testl %r8d, %r8d
jle 0x2f7c
movq 0x8(%rsp), %rax
movslq %eax, %rbx
addl %r8d, %eax
movl %eax, 0x18(%rsp)
movq %rbx, %r13
shlq $0x5, %r13
xorl %r14d, %r14d
movq (%r15), %rdx
movq 0x8(%r15), %rax
subq %rdx, %rax
shrq $0x5, %rax
cltq
cmpq %rax, %rbx
jge 0x2f6f
movq 0x10(%r12), %rax
movq (%rax), %rsi
addq %r13, %rdx
movq (%rsi), %rax
leaq 0x48(%rsp), %rdi
movl $0x1, %ecx
callq *0x10(%rax)
leaq 0x5bec(%rip), %rax      # 0x8b18
movq %rax, 0x48(%rsp)
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x2f40
callq 0x350c
movq 0x18(%r12), %rax
movq -0x10(%rax), %rdi
movq 0x40(%rsp), %rax
movq (%rax), %rsi
addq %r13, %rsi
movq (%rdi), %rax
callq *0x18(%rax)
incq %rbx
decl %r14d
addq $0x20, %r13
cmpl %r14d, %ebp
jne 0x2ef5
movl 0x18(%rsp), %eax
jmp 0x2f77
movq 0x8(%rsp), %rax
subl %r14d, %eax
movq %rax, 0x8(%rsp)
movq 0x10(%r12), %r13
movq 0x18(%r12), %rax
subq %r13, %rax
cmpq $0x11, %rax
jb 0x3013
movl $0x1, %ebx
movl $0x18, %r14d
movq -0x8(%r13,%r14), %rdi
leaq 0x5cde(%rip), %rsi      # 0x8c88
leaq 0x5d77(%rip), %rdx      # 0x8d28
xorl %ecx, %ecx
callq 0x2170
movq (%r13,%r14), %r13
testq %r13, %r13
je 0x2fd9
movq 0x5ff7(%rip), %rcx      # 0x8fc0
cmpb $0x0, (%rcx)
je 0x2fd4
incl 0x8(%r13)
jmp 0x2fd9
lock
incl 0x8(%r13)
movss 0xc(%r12), %xmm0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x28(%rcx)
testq %r13, %r13
je 0x2ff6
movq %r13, %rdi
callq 0x350c
incq %rbx
movq 0x10(%r12), %r13
movq 0x18(%r12), %rax
subq %r13, %rax
sarq $0x4, %rax
addq $0x10, %r14
cmpq %rax, %rbx
jb 0x2f9e
movl 0x1c(%rsp), %eax
incl %eax
cmpl 0x38(%rsp), %eax
movq 0x30(%rsp), %r8
jl 0x2ecf
movq 0x28(%rsp), %rax
incl %eax
movl 0x14(%rsp), %ecx
cmpl %ecx, %eax
jne 0x2ea0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x20a0
leaq 0x320d(%rip), %rcx      # 0x6268
movq %rcx, (%rax)
movq 0x5f4b(%rip), %rsi      # 0x8fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21f0
movq %rax, %rbx
testq %r13, %r13
je 0x307f
movq %r13, %rdi
callq 0x350c
movq %rbx, %rdi
callq 0x2200
nop