小编Han*_*Qiu的帖子

numpy.array_split的有效逆运算是什么?

我正在使用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子数组合并为一个?

python numpy machine-learning

6
推荐指数
1
解决办法
2784
查看次数

为什么将按位NOT应用于char会产生一个int?

在我的笔记本电脑上,运行以下代码:

#include <iostream>
using namespace std;

int main()
{
    char a;
    cout << sizeof(~a) << endl;
}
Run Code Online (Sandbox Code Playgroud)

打印4.

我期望结果~achar,但显然,它是一个int.

这是为什么?

c++

2
推荐指数
1
解决办法
78
查看次数

在二维 NumPy 数组中查找最近的非零元素和相应的索引

假设我有一个名为 2d 的数组array和一个 2d 索引:(x,y)并且我想获得最近的非零元素到(x,y),并获得元素的相应索引np.nonzero(array)

python numpy

2
推荐指数
1
解决办法
1676
查看次数

我的c ++代码出了什么问题?

这是代码.

#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; ^

c++

1
推荐指数
1
解决办法
120
查看次数

标签 统计

c++ ×2

numpy ×2

python ×2

machine-learning ×1