我已从 2D 矢量中的文本文件加载数据。我正在明智地提取数据列,在每列中找到最小值,最大值,然后对其进行规范化。标准化数据存储在一个单独的临时向量中,请记住我从列中提取数据,因此它应该返回到列中。我需要从归一化的单个临时向量重建原始 2D 向量。
vector <vector<double> >loadedData;
vector <double> normal;
vector <double> temp;
vector <vector <double> >normalDataFrom1D;
normalDataFrom1D.resize(rows, vector<double>(cols,0.0));
loadedData = net.loadData(file);
int cols = net.no_of_cols("../sampleData.txt");
int rows = net.no_of_rows("../sampleData.txt");
for(int i=0;i<cols;i++){
min = net.min_1d(i);
max = net.max_1d(i);
cout<<"Min val in Col ["<<i<<"] data :"<<min<<endl;
cout<<"Max val in Col ["<<i<<"] data :"<<max<<endl;
normal = net.extract_1d(i);
temp = net.normalizeData_1d(normal, min, max);
for(int r=0;r<normalDataFrom1D.size();r++){
for(int c=0;c<normalDataFrom1D[r].size();c++){
normalDataFrom1D[c][r] = temp;
}
}
}
//Printing Data...
for(int r=0;r<normalDataFrom1D.size();r++){
for(int c=0;c<normalDataFrom1D[r].size();c++){
cout<<"Data in normalDataFrom1D["<<r<<"]["<<c<<"] = "<<normalDataFrom1D[r][c]<<endl;
}
}
error: cannot convert ‘std::vector<double>’ to ‘double’ in assignment
normalDataFrom1D[c][r] = temp;
如果我尝试:
temp[i].push_back(net.normalizeData_1d(normal, min, max));
它说:
error: request for member ‘push_back’ in ‘temp.std::vector<_Tp, _Alloc>::operator[]<double, std::allocator<double> >(((std::vector<double>::size_type)i))’, which is of non-class type ‘double’
temp[i].push_back(net.normalizeData_1d(normal, min, max));