本文整理汇总了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);
}
示例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;
}
示例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;
}