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


C++ mat::reshape方法代码示例

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


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

示例1: GenerateDistractedSequence

/*
 * This sample is a simplified version of Derek D. Monner's Distracted Sequence
 * Recall task, which involves 10 symbols:
 *
 * Targets: must be recognized and remembered by the network.
 * Distractors: never need to be remembered.
 * Prompts: direct the network to give an answer.
 *
 * A single trial consists of a temporal sequence of 10 input symbols. The first
 * 8 consist of 2 randomly chosen target symbols and 6 randomly chosen
 * distractor symbols in an random order. The remaining two symbols are two
 * prompts, which direct the network to produce the first and second target in
 * the sequence, in order.
 *
 * For more information, see the following paper.
 *
 * @code
 * @misc{Monner2012,
 *   author = {Monner, Derek and Reggia, James A},
 *   title = {A generalized LSTM-like training algorithm for second-order
 *   recurrent neural networks},
 *   year = {2012}
 * }
 * @endcode
 *
 * @param input The generated input sequence.
 * @param input The generated output sequence.
 */
void GenerateDistractedSequence(arma::mat& input, arma::mat& output)
{
  input = arma::zeros<arma::mat>(10, 10);
  output = arma::zeros<arma::mat>(3, 10);

  arma::Col<size_t> index = arma::shuffle(arma::linspace<arma::Col<size_t> >(
      0, 7, 8));

  // Set the target in the input sequence and the corresponding targets in the
  // output sequence by following the correct order.
  for (size_t i = 0; i < 2; i++)
  {
    size_t idx = rand() % 2;
    input(idx, index(i)) = 1;
    output(idx, index(i) > index(i == 0) ? 9 : 8) = 1;
  }

  for (size_t i = 2; i < 8; i++)
    input(2 + rand() % 6, index(i)) = 1;


  // Set the prompts which direct the network to give an answer.
  input(8, 8) = 1;
  input(9, 9) = 1;

  input.reshape(input.n_elem, 1);
  output.reshape(output.n_elem, 1);
}
开发者ID:AmesianX,项目名称:mlpack,代码行数:56,代码来源:recurrent_network_test.cpp

示例2: pMatC

// [[Rcpp::export]]
arma::mat pMatC(arma::mat p){

	arma::mat Pmat(4,4);
	Pmat.zeros();
	arma::mat revI(4,4);
	revI.zeros();
	
	//int n1=p.n_rows, n2=p.n_cols;
	
	//if(n1!=4 && n2!=4){}
	
	p.reshape(4,1);
	Pmat.col(0)=p;

	revI(0,1) = -1;revI(1,0) = 1;	revI(2,3) = 1; revI(3,2) = -1;
	Pmat.col(1) = revI*p;

	revI.zeros();
	revI(0,2) = -1;revI(1,3) = -1;	revI(2,0) = 1; revI(3,1) = 1;
	Pmat.col(2) = revI*p;

	revI.zeros();
	revI(0,3) = -1;revI(1,2) = 1;	revI(2,1) = -1; revI(3,0) = 1;
	Pmat.col(3)=revI*p;
	

	return Pmat;
}
开发者ID:cran,项目名称:rotations,代码行数:29,代码来源:basics.cpp

示例3: simple_dlyap

bool subspaceIdMoor::simple_dlyap(arma::mat const &A, arma::mat const &Q, arma::mat &X){
	mat kronProd = kron(A, A);
	mat I = eye(kronProd.n_rows, kronProd.n_cols);
	bool slvflg = solve(X, I - kronProd, vectorise(Q));

	/*Reshape vec to matrix:*/
	X.reshape(A.n_rows, A.n_rows);
	return slvflg;
}
开发者ID:caiofcm,项目名称:backup-functions,代码行数:9,代码来源:subspaceIdMoor_backup.cpp


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