当前位置: 首页>>代码示例>>C++>>正文


C++ cube::slices方法代码示例

本文整理汇总了C++中cube::slices方法的典型用法代码示例。如果您正苦于以下问题:C++ cube::slices方法的具体用法?C++ cube::slices怎么用?C++ cube::slices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cube的用法示例。


在下文中一共展示了cube::slices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: train

double NeuralNet::train(cube x,cube y, double alpha, long int epoch){
    
    double cst = 0 ;
    int rnd = 0;
    cube sample_x;
    cube sample_y;

    for(int i=0; i < epoch; i++){
        rnd = rand() % (x.n_slices - 1);
        sample_x =(x.slices(rnd, rnd));
        sample_y =(y.slices(rnd, rnd));
        cst = computeCost(sample_x, sample_y);
        backprop(sample_x, sample_y);
        updateWeights(alpha);
        cout << "Epoch[" << i << "]: " << cst << endl;
    }


    
    double total = 0;
    double ctotal = 0;
    for(int i=0; i < x.n_slices; i++){
        sample_x = (x.slices(i,i));
        sample_y = (y.slices(i,i));
        cst = computeCost(sample_x, sample_y);
        total += cst;
        
        // classification error:
        uword rid, cid, sid;
        cube p = pred(sample_x);
        p.max(rid,cid,sid);
        if(sample_y(rid,cid,sid) == 1)
            ctotal++;   
    }
    total  /= x.n_slices;
    ctotal /= x.n_slices;
    cout << "Mean Training Error: " << total << endl;
    cout << "Classification Error: " << ctotal << endl;
    return 0;
}
开发者ID:pshirasb,项目名称:NeuralNet,代码行数:40,代码来源:convnn.cpp

示例2: white

void white(const mat& x1, const mat& x2, const uvec& sti, const cube& matphi1, const cube& matphi2, cube& wX, const uvec& End, const uvec & wEnd){
	int T = x1.n_rows, L = matphi1.n_slices, P = x1.n_cols, m = End.n_elem-1;
	mat multiply(P,P);
	cube X(3*P,P,T);
	for(int t=0;t<T;t++){
		X.slice(t)=join_cols(join_cols(diagmat(x1.row(t)),diagmat(x2.row(t))),diagmat(ones(1,P)));
	}
	for(int run=0;run<m;run++){
		wX.slices(wEnd[run],wEnd[run+1]-1) = X.slices(End[run]+L,End[run+1]-1);
		if(L>0){
			for(unsigned int t=End[run]+L;t<End[run+1];t++){
				for(int l=0;l<L;l++){
					multiply = sti[t-l-1]?(matphi1.slice(l)):(matphi2.slice(l));
					wX.slice(t-L*(run+1)) -= X.slice(t-l-1)*multiply;
				}
			}
		}
	}
}
开发者ID:soapless,项目名称:Hierarchical_BVAR_fMRI_multisub,代码行数:19,代码来源:side_code.cpp


注:本文中的cube::slices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。