我正在使用cross_validation来选择超参数,然后将训练数据分成k折。以一个文件夹作为验证数据,以另一个文件夹作为训练数据(k实际上,我有时会这样做)。
X_train_folds = numpy.array_split(X_train,k)
Run Code Online (Sandbox Code Playgroud)
该X_tran_folds会是这样的:[subarray1,subarray2,.....]
子数组的列数相同。
但是如何将k-1子数组合并为一个?
在我的笔记本电脑上,运行以下代码:
#include <iostream>
using namespace std;
int main()
{
char a;
cout << sizeof(~a) << endl;
}
Run Code Online (Sandbox Code Playgroud)
打印4.
我期望结果~a是char,但显然,它是一个int.
这是为什么?
假设我有一个名为 2d 的数组array和一个 2d 索引:(x,y)并且我想获得最近的非零元素到(x,y),并获得元素的相应索引np.nonzero(array)
这是代码.
#include <iostream>
#include <cstring>
using namespace std;
class Headquarter
{
private:
//num of total warriors
int totalNum;
public:
int getTotalNum() ;
};
int Headquarter::getTotalNum()
{ return totalNum; }
int main()
{
Headquarter a;
Headquarter *p =&a;
cout << (p->getTotalNum) << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我无法用g ++,4.8.4编译它.我不知道它有什么问题.这是错误的信息:
test.cpp: In function ‘int main()’:
test.cpp:19:7: error: no match for ‘operator<<’ (operand types are std::ostream {aka std::basic_ostream<char>}’ and ‘<unresolved>`overloaded function type>’)
Run Code Online (Sandbox Code Playgroud)
cout <<(p-> getTotalNum)<< endl; ^