本文整理汇总了C++中arma::Mat::rows方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat::rows方法的具体用法?C++ Mat::rows怎么用?C++ Mat::rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arma::Mat
的用法示例。
在下文中一共展示了Mat::rows方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gpu_train_batch
inline void gpu_train_batch(FeedForward_Network<activation, error>& network,
arma::Mat<float> inputs, arma::Mat<float> targets, int batch_size, float learning_rate = 0.8f, float momentum = 0.8f) {
network.resize_activation(batch_size);
Raw_FeedForward_Network<activation, error> raw_net = convert_to_raw(network);
Raw_FeedForward_Network<activation, error> * d_network = network_to_gpu(raw_net);
int batches_in_train = targets.n_rows/batch_size - 1;
for (int i = 0; i < batches_in_train; ++i) {
arma::Mat<float> input_slice = inputs.rows(i*batch_size, (i+1) * batch_size - 1);
Raw_Matrix raw_input = to_raw(input_slice);
Raw_Matrix * d_input = matrix_to_gpu(raw_input);
int num_trials = input_slice.n_rows;
calculate_activation(num_trials, network.layer_sizes, d_network, d_input);
//TODO make this memory shared as to not realloc
free_gpu_matrix(d_input);
arma::Mat<float> targets_slice = targets.rows(i*batch_size, (i+1) * batch_size - 1);
Raw_Matrix raw_targets = to_raw(targets_slice);
Raw_Matrix * d_targets = matrix_to_gpu(raw_targets);
backprop(num_trials, network.layer_sizes, d_network, d_targets, learning_rate, momentum);
free_gpu_matrix(d_targets);
}
network_to_cpu_free(d_network, raw_net);
update_from_raw(network, raw_net);
}
示例2: Impute
/**
* Impute function searches through the input looking for mappedValue and
* remove the whole row or column. The result is overwritten to the input.
*
* @param input Matrix that contains mappedValue.
* @param mappedValue Value that the user wants to get rid of.
* @param dimension Index of the dimension of the mappedValue.
* @param columnMajor State of whether the input matrix is columnMajor or not.
*/
void Impute(arma::Mat<T>& input,
const T& mappedValue,
const size_t dimension,
const bool columnMajor = true)
{
std::vector<arma::uword> colsToKeep;
if (columnMajor)
{
for (size_t i = 0; i < input.n_cols; ++i)
{
if (!(input(dimension, i) == mappedValue ||
std::isnan(input(dimension, i))))
{
colsToKeep.push_back(i);
}
}
input = input.cols(arma::uvec(colsToKeep));
}
else
{
for (size_t i = 0; i < input.n_rows; ++i)
{
if (!(input(i, dimension) == mappedValue ||
std::isnan(input(i, dimension))))
{
colsToKeep.push_back(i);
}
}
input = input.rows(arma::uvec(colsToKeep));
}
}