// File: lipiji[P]PG_DEEP/deep.cpp
// Function: DBN::DBN(Dataset, Conf)
DBN::DBN(Dataset data, Conf conf)
{
    n_samples = data.N;
    n_features = data.n_f;
    n_layers = conf.n_layers;
    n_labels = conf.n_labels;
    lamda = conf.lamda;
    alpha = conf.learning_rate;

    rbm_layers = new RBM*[n_layers];
    hidden_layer_size = new int[n_layers];
    for(int i=0; i<n_layers; i++)
    {
        hidden_layer_size[i] = conf.hidden_layer_size[i];
        if(i == 0)
        {
            rbm_layers[i] = new RBM(n_samples, n_features, hidden_layer_size[i], NULL, NULL, NULL, conf.lamda, 0.5);
        }
        else
        {
            rbm_layers[i] = new RBM(n_samples, hidden_layer_size[i-1], hidden_layer_size[i],  NULL, NULL, NULL, conf.lamda, 0.5);
        }
    }

    //logistic layer
    lr_layer = new LR(n_samples, hidden_layer_size[n_layers-1], n_labels, conf.lamda);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdx, -0x40(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movl (%rsi), %ecx
movl %ecx, (%rax)
movl 0x4(%rsi), %ecx
movl %ecx, 0x4(%rax)
movl 0xa0(%rdx), %ecx
movl %ecx, 0x8(%rax)
movl 0xa4(%rdx), %ecx
movl %ecx, 0xc(%rax)
movsd 0xa8(%rdx), %xmm0
movsd %xmm0, 0x18(%rax)
movsd 0x98(%rdx), %xmm0
movsd %xmm0, 0x20(%rax)
movslq 0x8(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x28(%rax)
movslq 0x8(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x1c(%rbp)
movq -0x38(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x6f76
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movq 0x88(%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
cmpl $0x0, -0x1c(%rbp)
jne 0x6ed6
movl $0x40, %edi
callq 0x2220
movq -0x38(%rbp), %rcx
movq %rax, %rdi
movq -0x40(%rbp), %rax
movq %rdi, %rdx
movq %rdx, -0x48(%rbp)
movl (%rcx), %esi
movl 0x4(%rcx), %edx
movq 0x10(%rcx), %rcx
movslq -0x1c(%rbp), %r8
movl (%rcx,%r8,4), %ecx
movsd 0xa8(%rax), %xmm0
movq %rsp, %rax
movq $0x0, (%rax)
xorl %eax, %eax
movl %eax, %r9d
movsd 0x4244(%rip), %xmm1     # 0xb0d8
movq %r9, %r8
callq 0x5bf0
jmp 0x6e9e
movq -0x48(%rbp), %rdx
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x6f66
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x40, %esi
callq 0x2230
jmp 0x6fe4
movl $0x40, %edi
callq 0x2220
movq -0x38(%rbp), %rcx
movq %rax, %rdi
movq -0x40(%rbp), %rax
movq %rdi, %rdx
movq %rdx, -0x50(%rbp)
movl (%rcx), %esi
movq 0x10(%rcx), %rcx
movslq -0x1c(%rbp), %r8
movl %r8d, %edx
decl %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %edx
movl (%rcx,%r8,4), %ecx
movsd 0xa8(%rax), %xmm0
movq %rsp, %rax
movq $0x0, (%rax)
xorl %eax, %eax
movl %eax, %r9d
movsd 0x41ae(%rip), %xmm1     # 0xb0d8
movq %r9, %r8
callq 0x5bf0
jmp 0x6f34
movq -0x50(%rbp), %rdx
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x6f66
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x40, %esi
callq 0x2230
jmp 0x6fe4
jmp 0x6f68
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x6e0d
movl $0x28, %edi
callq 0x2220
movq -0x38(%rbp), %rcx
movq %rax, %rdi
movq -0x40(%rbp), %rax
movq %rdi, %rdx
movq %rdx, -0x58(%rbp)
movq 0x10(%rcx), %rdx
movl (%rcx), %esi
movl 0x8(%rcx), %r8d
decl %r8d
movslq %r8d, %r8
movl (%rdx,%r8,4), %edx
movl 0xc(%rcx), %ecx
movsd 0xa8(%rax), %xmm0
callq 0x66e0
jmp 0x6fb8
movq -0x38(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, 0x30(%rax)
addq $0x60, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x28, %esi
callq 0x2230
movq -0x28(%rbp), %rdi
callq 0x23a0
nopl (%rax)