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


C++ VectorXd::unaryExpr方法代码示例

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


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

示例1: trainGP

bool CVarianceDecomposition::trainGP() 
{

	bool conv = false;
	// initGP if is not init
	if (this->is_init==0)	this->initGP();

	//train GP
	conv = this->opt->opt();

	//check convergence
    VectorXd scales;
    this->agetScales(&scales);
    conv &= (scales.unaryExpr(std::bind2nd( std::ptr_fun<double,double,double>(pow), 2) ).maxCoeff()<(mfloat_t)10.0);

	return conv;
}
开发者ID:BioinformaticsArchive,项目名称:limix,代码行数:17,代码来源:CVarianceDecomposition.cpp

示例2: FireSingleLayer

VectorXd LayeredFeedForwardNeuralNet::FireSingleLayer(const VectorXd& inputActivations, long layerIndex) const
{
    // get layer input weights (also checks valid layerIndex)
    const MatrixXd& layerInputWeights = GetLayerInputWeights(layerIndex);
    
    if (layerInputWeights.cols() - 1 != inputActivations.size())
    {
        // input is invalid for this neural net topology
        throw NeuralNetTopologyMismatch("activation input must match number of units in neural network layer");
    }
    
    // get the activation function
    auto expressionParser = UnaryExpressionParserFactory::CreateParser();
    UnaryFunction activationFunction = expressionParser->GetFunctionForExpression(m_activationFunction);
    
    // bias activation
    VectorXd bias(1);
    bias << -1.0;
    
    // calculate layer net inputs
    VectorXd inputPlusBias(layerInputWeights.cols());
    inputPlusBias << inputActivations, bias;
    
    //std::cout << "layer " << layerIndex << " input activations +bias : " << std::endl << inputPlusBias << std::endl << std::endl;
    //std::cout << "layer " << layerIndex << " input weights : " << std::endl << layerInputWeights << std::endl << std::endl;
    
    VectorXd layerNetInputs = layerInputWeights * inputPlusBias;
    
    //std::cout << "layer " << layerIndex << " net inputs : " << std::endl << layerNetInputs << std::endl << std::endl;
    
    // calculate layer activations
    VectorXd layerActivations = layerNetInputs.unaryExpr(activationFunction);
    
    //std::cout << "layer " << layerIndex << " output activations : " << layerActivations << std::endl << std::endl;
    
    return layerActivations;
}
开发者ID:philmccarthy24,项目名称:FFNeuralNet,代码行数:37,代码来源:LayeredFeedForwardNeuralNet.cpp

示例3: sgm

VectorXd D_P_ANN_Controller::sgm(VectorXd x){
  VectorXd W_in;
  W_in=x.unaryExpr(std::ptr_fun(sigmoid));
  if(thresholdNo) W_in(0)=1;
  return W_in;
}
开发者ID:vakker,项目名称:thesis,代码行数:6,代码来源:d_p_ann_controller.cpp


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