// File: /workspace/github_cpp_makefile_star2_O2/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 $0x78, %rsp
movq %rdx, 0x40(%rsp)
cmpb $0x1, 0x8(%rdi)
jne 0x2be2
movq %rsi, %r15
movq %rdi, %r12
movslq %r8d, %rax
testl %eax, %eax
movl $0x0, %edx
movq %rax, 0x28(%rsp)
cmovgl %eax, %edx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
movq %rdx, 0x30(%rsp)
negl %edx
movl %edx, 0x24(%rsp)
movl %ecx, 0x14(%rsp)
cmpl %ecx, %eax
je 0x2bd3
movl %eax, 0x18(%rsp)
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x5, %rax
movq $0x0, 0x8(%rsp)
xorl %edx, %edx
divq 0x28(%rsp)
movq %rax, 0x38(%rsp)
xorl %eax, %eax
cmpl 0x38(%rsp), %eax
jge 0x2bc4
movl %eax, 0x20(%rsp)
movq 0x8(%rsp), %rcx
movslq %ecx, %rbp
movq 0x30(%rsp), %rax
addl %ecx, %eax
movl %eax, 0x1c(%rsp)
movq %rbp, %r13
shlq $0x5, %r13
xorl %ebx, %ebx
cmpl %ebx, 0x24(%rsp)
je 0x2b55
movq (%r15), %rdx
movq 0x8(%r15), %rax
subq %rdx, %rax
shrq $0x5, %rax
cltq
cmpq %rax, %rbp
jge 0x2b5b
movq 0x10(%r12), %rax
movq (%rax), %rsi
addq %r13, %rdx
movq (%rsi), %rax
leaq 0x58(%rsp), %r14
movq %r14, %rdi
pushq $0x1
popq %rcx
callq *0x10(%rax)
movq %r14, %rdi
callq 0x2d7e
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 %rbp
decl %ebx
addq $0x20, %r13
jmp 0x2af1
movl 0x1c(%rsp), %eax
jmp 0x2b62
movq 0x8(%rsp), %rax
subl %ebx, %eax
movq %rax, 0x8(%rsp)
pushq $0x10
popq %rbx
pushq $0x1
popq %r13
leaq 0x50(%rsp), %rbp
movq 0x10(%r12), %rsi
movq 0x18(%r12), %rax
subq %rsi, %rax
sarq $0x4, %rax
cmpq %rax, %r13
jae 0x2bb9
addq %rbx, %rsi
leaq 0x48(%rsp), %rdi
callq 0x45e1
movq 0x48(%rsp), %rdi
movss 0xc(%r12), %xmm0
movq (%rdi), %rax
callq *0x28(%rax)
movq %rbp, %rdi
callq 0x30a6
incq %r13
addq $0x10, %rbx
jmp 0x2b73
movl 0x20(%rsp), %eax
incl %eax
jmp 0x2ac7
movl 0x18(%rsp), %eax
incl %eax
movl 0x14(%rsp), %ecx
jmp 0x2a99
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x20a0
leaq 0x2657(%rip), %rcx      # 0x5248
movq %rcx, (%rax)
movq 0x63b5(%rip), %rsi      # 0x8fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x21d0
movq %rax, %rbx
movq %rbp, %rdi
callq 0x30a6
movq %rbx, %rdi
callq 0x21e0