Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hierarchical dcat declarations break AD in a model #1500

Open
paciorek opened this issue Oct 23, 2024 · 0 comments
Open

hierarchical dcat declarations break AD in a model #1500

paciorek opened this issue Oct 23, 2024 · 0 comments
Assignees
Labels

Comments

@paciorek
Copy link
Contributor

Simplifying from a user post on 2024-10-22, this causes model building to fail because of AD. Note that in testing we have a latent dcat with a dependent dnorm and that is fine. So something about the two dcats may be the issue.

code <- nimbleCode({
    y ~ dcat(p[z,1:2])
    for(i in 1:2) {
      p[i,1]~dunif(0,1)
      p[i,2]<-1-p[i,1]
    }
    z ~ dcat(p[1,1:2])
    
})
m <- nimbleModel(code,buildDerivs=TRUE)
cm <- compileNimble(m)
using C++ compiler: ‘g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
In file included from P_1_code_MID_1.h:6,
                 from P_1_code_MID_1.cpp:7:
/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.4/nimble/include/nimble/NimArr.h: In instantiation of ‘NimArr<nDim, T>& VecNimArr<ndim, T>::operator[](unsigned int) [with int ndim = 1; T = double]’:
P_1_code_MID_1.cpp:28:10:   required from here
/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.4/nimble/include/nimble/NimArr.h:1862:35: warning: format ‘%i’ expects argument of type ‘int’, but argument 3 has type ‘std::vector<NimArr<1, double>, std::allocator<NimArr<1, double> > >::size_type’ {aka ‘long unsigned int’} [-Wformat=]
 1862 |           "values.size() is only %i\n",
      |                                  ~^
      |                                   |
      |                                   int
      |                                  %li
 1863 |           i, values.size());
      |              ~~~~~~~~~~~~~         
      |                         |
      |                         std::vector<NimArr<1, double>, std::allocator<NimArr<1, double> > >::size_type {aka long unsigned int}
/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.4/nimble/include/nimble/NimArr.h: In instantiation of ‘NimArr<nDim, T>& VecNimArr<ndim, T>::operator[](unsigned int) [with int ndim = 2; T = double]’:
P_1_code_MID_1.cpp:29:10:   required from here
/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.4/nimble/include/nimble/NimArr.h:1862:35: warning: format ‘%i’ expects argument of type ‘int’, but argument 3 has type ‘std::vector<NimArr<2, double>, std::allocator<NimArr<2, double> > >::size_type’ {aka ‘long unsigned int’} [-Wformat=]
 1862 |           "values.size() is only %i\n",
      |                                  ~^
      |                                   |
      |                                   int
      |                                  %li
 1863 |           i, values.size());
      |              ~~~~~~~~~~~~~         
      |                         |
      |                         std::vector<NimArr<2, double>, std::allocator<NimArr<2, double> > >::size_type {aka long unsigned int}
/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.4/nimble/include/nimble/NimArr.h: In instantiation of ‘NimArr<nDim, T>& VecNimArr<ndim, T>::operator[](unsigned int) [with int ndim = 1; T = CppAD::AD<double>]’:
P_1_code_MID_1.cpp:113:10:   required from here
/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.4/nimble/include/nimble/NimArr.h:1862:35: warning: format ‘%i’ expects argument of type ‘int’, but argument 3 has type ‘std::vector<NimArr<1, CppAD::AD<double> >, std::allocator<NimArr<1, CppAD::AD<double> > > >::size_type’ {aka ‘long unsigned int’} [-Wformat=]
 1862 |           "values.size() is only %i\n",
      |                                  ~^
      |                                   |
      |                                   int
      |                                  %li
 1863 |           i, values.size());
      |              ~~~~~~~~~~~~~         
      |                         |
      |                         std::vector<NimArr<1, CppAD::AD<double> >, std::allocator<NimArr<1, CppAD::AD<double> > > >::size_type {aka long unsigned int}
/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.4/nimble/include/nimble/NimArr.h: In instantiation of ‘NimArr<nDim, T>& VecNimArr<ndim, T>::operator[](unsigned int) [with int ndim = 2; T = CppAD::AD<double>]’:
P_1_code_MID_1.cpp:114:10:   required from here
/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-22.04/4.4/nimble/include/nimble/NimArr.h:1862:35: warning: format ‘%i’ expects argument of type ‘int’, but argument 3 has type ‘std::vector<NimArr<2, CppAD::AD<double> >, std::allocator<NimArr<2, CppAD::AD<double> > > >::size_type’ {aka ‘long unsigned int’} [-Wformat=]
 1862 |           "values.size() is only %i\n",
      |                                  ~^
      |                                   |
      |                                   int
      |                                  %li
 1863 |           i, values.size());
      |              ~~~~~~~~~~~~~         
      |                         |
      |                         std::vector<NimArr<2, CppAD::AD<double> >, std::allocator<NimArr<2, CppAD::AD<double> > > >::size_type {aka long unsigned int}
P_1_code_MID_1_nfCode.cpp: In member function ‘virtual CppAD::AD<double> y_L1_UID_4::calculate_ADproxyModel(const indexedNodeInfo&) const’:
P_1_code_MID_1_nfCode.cpp:120:37: error: invalid ‘static_cast’ from type ‘CppAD::AD<double>’ to type ‘int’
  120 | Interm_8.setMap((**ADproxyModel_p), static_cast<int>(((**ADproxyModel_z)[0] - 1) * (**ADproxyModel_p).strides()[0]), (**ADproxyModel_p).strides()[1], 2);
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants