none
error C2664 RRS feed

  • Question

  • I have a program that I want to place 1D pointers to vectors in a 2D pointers to vectors in each iteration of a loop but I don't know why I received the error in this program. could anyone help me ?? 

    error C2664: 'void encoder(const std::vector<double,std::allocator<_Ty>> *,int,int,const std::vector<_Ty,std::allocator<_Ty>> *,int,int,const std::vector<_Ty,std::allocator<_Ty>> *,std::vector<_Ty,std::allocator<_Ty>> *,std::string)' : cannot convert argument 4 from 'std::vector<double,std::allocator<_Ty>>' to 'const std::vector<double,std::allocator<_Ty>> *' G:\run_gpu_sample\project_4\project_4\Autoencoder.cpp

    void encoder(const std::vector<double>*x_train , int row_Xtrain, int col_Xtrain,const std::vector< double> *a_f, int row_af, int col_af, const std::vector<double>*b_f,std::vector< double>* H_F, std::string G);

    void Autoencoder(int n, int L, vector<double>*X_train, vector<double>*X_test){
    int k = 0 , i=0 , l=0 , t=0;

    vector<double>*a_f = new vector<double>(COL* NERUN);
    vector<double>*b_f = new vector<double>(NERUN);
    vector<double>*H_F = new vector<double>(row_Data_train * NERUN);
    vector<double>*HF_sudoinverse = new vector<double>(NERUN * row_Data_train);
    vector<double>*b_n = new vector<double>(NERUN);
    vector<double>*a_n = new vector<double>(NERUN * COL);
    vector<double>*a_f_new = new vector<double>(NERUN * NERUN);
    vector<double>*b_f_new = new vector<double>(NERUN);
    vector<vector<double>>*a_F = new vector<vector<double>>();
    vector<vector<double>>*b_F = new vector<vector<double>>();
    vector<double>*H_n_train = new vector<double>();
    vector<double>*H_n_test = new vector<double>();


    *a_f_new = rand_data(NERUN * NERUN);
    *b_f_new = rand_data(NERUN);

    while (k < L){
    if (k == 0){
    *a_f = rand_data(COL_NERUN);
    *b_f = rand_data(NERUN);
    decoder(X_train, row_Data_train, COL, a_f, COL, NERUN, b_f, H_F, HF_sudoinverse, a_n, NERUN, COL, b_n, "sigmoid", 300, 200);
    double *d_a_n, *d_a_f;
    cudaMalloc((void **)&d_a_n, sizeof(double)* NERUN* COL);
    cudaMalloc((void **)&d_a_f, sizeof(double)* NERUN* COL);
    cudaMemcpy(d_a_n, a_n->data(), sizeof(double)* NERUN* COL, cudaMemcpyHostToDevice);
    Transpose(d_a_f, d_a_n, NERUN, COL);
    cudaMemcpy(a_f->data(), d_a_f, sizeof(double)* a_n->size(), cudaMemcpyDeviceToHost);
    for (i = 0; i < NERUN ; i++){
    (*b_f)[i] = (*b_n)[i];}
    }
    else if (k < L){
    decoder(X_train, row_Data_train, COL, a_f, COL, NERUN, b_f, H_F, HF_sudoinverse, a_n, NERUN, COL, b_n, "sigmoid", 300, 200);
    double *d_a_n, *d_a_f;
    cudaMalloc((void **)&d_a_n, sizeof(double)* NERUN* COL);
    cudaMalloc((void **)&d_a_f, sizeof(double)*NERUN* COL);
    cudaMemcpy(d_a_n, a_n->data(), sizeof(double)* NERUN* COL, cudaMemcpyHostToDevice);
    Transpose(d_a_f, d_a_n, NERUN, COL);
    cudaMemcpy(a_f->data(), d_a_f, sizeof(double)* NERUN* COL, cudaMemcpyDeviceToHost);
    for (i = 0; i < b_n->size(); i++){
    (*b_f)[i] = (*b_n)[i];}
    }
    k++;
    }
    while (l < n){
    if (l == 0){
    decoder(X_train, row_Data_train, COL, a_f, COL, NERUN, b_f, H_F, HF_sudoinverse, a_n, NERUN, COL, b_n, "sigmoid", 300, 200);
    }
    else{
    a_f->resize(NERUN * NERUN);
    *a_f = rand_data(NERUN * NERUN);
    *b_f = rand_data(NERUN);
    a_n->resize(NERUN * NERUN);
    decoder(H_F, row_Data_train, COL, a_f, COL, NERUN, b_f, H_F, HF_sudoinverse, a_n, NERUN, COL, b_n, "sigmoid", 300, 200);
    }
    a_F->push_back(vector<double>());
    for (i = 0; i < a_f->size(); i++){
    (*a_F)[l].push_back((*a_f)[i]);
    }
    b_F->push_back(vector<double>());
    for (i = 0; i < b_f->size(); i++){
    (*b_F)[l].push_back((*b_f)[i]);
    }
    if (l == n - 1)
    H_n_train = H_F;
    l++;
    }

    while (t < n){
    if (t == 0)
    encoder(X_test, row_Data_test, COL, (*a_F)[t], COL*NERUN, 0, (*b_F)[t] , H_F, "sigmoid");
    else if (t < n - 1)
    encoder(H_F, row_Data_test, NERUN, (*a_F)[t], NERUN * NERUN , t ,(*b_F)[t], H_F, "sigmoid");
    else
    encoder(H_F, row_Data_test, NERUN, (*a_F)[t], NERUN * NERUN , n-1 ,(*b_F)[t], H_n_test, "sigmoid");
    t++;
    }

    }

    The main problem in this section of code that I want to use values of (*a_F)[t] and (*b_F)[t]  in each iteration in a loop. what is the problem ? could anyone help me? 

    while (t < n){
    if (t == 0)
    encoder(X_test, row_Data_test, COL, (*a_F)[t], COL*NERUN, 0, (*b_F)[t] , H_F, "sigmoid");
    else if (t < n - 1)
    encoder(H_F, row_Data_test, NERUN, (*a_F)[t], NERUN * NERUN , t ,(*b_F)[t], H_F, "sigmoid");
    else
    encoder(H_F, row_Data_test, NERUN, (*a_F)[t], NERUN * NERUN , n-1 ,(*b_F)[t], H_n_test, "sigmoid");
    t++;
    }

    Best regards
    Arezoo Moradi

    Sunday, September 8, 2019 6:00 AM

All replies

  • Try ‘&(*a_F)[t]’ or change the function encoder to receive a ‘const std::vector< double> & a_f’ argument.

    Sunday, September 8, 2019 8:06 AM
  • Thanks to your response
    Tuesday, September 10, 2019 12:58 PM
  • Hi,

    Have you got any updates? If your case has been solved, please help to mark answers. If not, just feel free to contact us.

    Your understanding and cooperation will be grateful.

    Best Regards,

    Jeanine Zhang


    Wednesday, September 11, 2019 1:15 AM
    Moderator