• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ arma::Cube类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Optimize

 void Optimize(arma::Cube<eT>& weights,
               arma::Cube<eT>& gradient,
               arma::Cube<eT>& momWeights)
 {
   for (size_t s = 0; s < weights.n_slices; s++)
     Optimize(weights.slice(s), gradient.slice(s), momWeights.slice(s));
 }
开发者ID:GYengera,项目名称:mlpack,代码行数:7,代码来源:steepest_descent.hpp


示例2: Gradient

  void Gradient(arma::Cube<eT>& gradient)
  {
    gradient = arma::zeros<arma::Cube<eT> >(weights.n_rows, weights.n_cols,
        weights.n_slices);

    for (size_t outputmap = 0; outputmap < outputLayer.OutputMaps(); outputmap++)
    {
      for (size_t inputmap = 0, s = outputmap; inputmap < inputLayer.OutputMaps();
        inputmap++, s += OutputLayer().OutputMaps())
      {
        arma::Cube<eT> inputSlices = inputLayer.InputActivation().slices(
            inputmap * inputLayer.LayerSlices(), (inputmap + 1) *
            inputLayer.LayerSlices() - 1);

        arma::Cube<eT> deltaSlices = outputLayer.Delta().slices(
            outputmap * inputLayer.LayerSlices(),
            (outputmap + 1) * inputLayer.LayerSlices() - 1);

        arma::Cube<eT> output;
        GradientConvolutionRule::Convolution(inputSlices, deltaSlices, output);

        for (size_t i = 0; i < output.n_slices; i++)
          gradient.slice(s) += output.slice(i);

        gradient.slice(s) /= inputLayer.LayerSlices();
      }
    }
  }
开发者ID:suspy,项目名称:mlpack,代码行数:28,代码来源:conv_connection.hpp


示例3: Rotate180

void Rotate180(const arma::Cube<eT>& input, arma::Cube<eT>& output)
{
    output = arma::Cube<eT>(input.n_rows, input.n_cols, input.n_slices);

    // * left-right flip, up-down flip */
    for (size_t s = 0; s < output.n_slices; s++)
        output.slice(s) = arma::fliplr(arma::flipud(input.slice(s)));
}
开发者ID:shenzebang,项目名称:mlpack,代码行数:8,代码来源:conv_layer.hpp


示例4: Forward

  void Forward(const arma::Cube<eT>& input, arma::Cube<eT>& output)
  {
    output = arma::zeros<arma::Cube<eT> >(input.n_rows / kSize,
                            input.n_cols / kSize, input.n_slices);

    for (size_t s = 0; s < input.n_slices; s++)
      Pooling(input.slice(s), output.slice(s));
  }
开发者ID:shenzebang,项目名称:mlpack,代码行数:8,代码来源:pooling_layer.hpp


示例5:

arma::Cube<double> VanillaFeedForward::feedForward(
		const arma::Cube<double>& x) {
	const arma::Mat<double>& weightVector = mW.slice(0);
	const arma::Col<double>& xVector = arma::Col<double>(
			(const double*) x.begin(), x.size());
	;
	const arma::Col<double>& biasVector = mB;
	arma::Col<double> v = weightVector * xVector + biasVector;
	return arma::Cube<double>((const double*) v.begin(), 1, 1, v.size());
}
开发者ID:kenk42292,项目名称:mochi,代码行数:10,代码来源:VanillaFeedForward.cpp


示例6: integrate

void
NumericalTestTrialIntegrator<BasisFunctionType, ResultType, GeometryFactory>::
integrate(const std::vector<int> &elementIndices,
          const Shapeset<BasisFunctionType> &testShapeset,
          const Shapeset<BasisFunctionType> &trialShapeset,
          arma::Cube<ResultType> &result) const {
    const size_t pointCount = m_localQuadPoints.n_cols;
    const size_t elementCount = elementIndices.size();

    if (pointCount == 0 || elementCount == 0)
        return;
    // TODO: in the (pathological) case that pointCount == 0 but
    // elementCount != 0, set elements of result to 0.

    // Evaluate constants
    const int testDofCount = testShapeset.size();
    const int trialDofCount = trialShapeset.size();

    BasisData<BasisFunctionType> testBasisData, trialBasisData;
    GeometricalData<CoordinateType> geomData;

    size_t testBasisDeps = 0, trialBasisDeps = 0;
    size_t geomDeps = 0; // INTEGRATION_ELEMENTS;

    m_testTransformations.addDependencies(testBasisDeps, geomDeps);
    m_trialTransformations.addDependencies(trialBasisDeps, geomDeps);
    m_integral.addGeometricalDependencies(geomDeps);

    typedef typename GeometryFactory::Geometry Geometry;
    std::unique_ptr<Geometry> geometry(m_geometryFactory.make());

    CollectionOf3dArrays<BasisFunctionType> testValues, trialValues;

    result.set_size(testDofCount, trialDofCount, elementCount);

    testShapeset.evaluate(testBasisDeps, m_localQuadPoints, ALL_DOFS,
                          testBasisData);
    trialShapeset.evaluate(trialBasisDeps, m_localQuadPoints, ALL_DOFS,
                           trialBasisData);

    // Iterate over the elements
    for (size_t e = 0; e < elementCount; ++e) {
        const int elementIndex = elementIndices[e];
        m_rawGeometry.setupGeometry(elementIndex, *geometry);
        geometry->getData(geomDeps, m_localQuadPoints, geomData);
        if (geomDeps & DOMAIN_INDEX)
            geomData.domainIndex = m_rawGeometry.domainIndex(elementIndex);
        m_testTransformations.evaluate(testBasisData, geomData, testValues);
        m_trialTransformations.evaluate(trialBasisData, geomData, trialValues);

        m_integral.evaluate(geomData, testValues, trialValues, m_quadWeights,
                            result.slice(e));
    }
}
开发者ID:popsomer,项目名称:bempp,代码行数:54,代码来源:numerical_test_trial_integrator_imp.hpp


示例7: Optimize

 void Optimize(arma::Cube<eT>& weights,
               arma::Cube<eT>& gradient,
               arma::Cube<eT>& mean,
               arma::Cube<eT>& variance)
 {
   for (size_t s = 0; s < weights.n_slices; s++)
   {
     Optimize(weights.slice(s), gradient.slice(s), mean.slice(s),
         variance.slice(s));
   }
 }
开发者ID:Falit,项目名称:mlpack,代码行数:11,代码来源:adam.hpp


示例8: Optimize

 void Optimize(arma::Cube<eT>& weights,
               arma::Cube<eT>& gradient,
               arma::Cube<eT>& meanSquaredGradient,
               arma::Cube<eT>& meanSquaredGradientDx)
 {
   for (size_t s = 0; s < weights.n_slices; s++)
   {
     Optimize(weights.slice(s), gradient.slice(s), meanSquaredGradient.slice(s),
         meanSquaredGradientDx.slice(s));
   }
 }
开发者ID:GYengera,项目名称:mlpack,代码行数:11,代码来源:ada_delta.hpp


示例9: Backward

  void Backward(const arma::Cube<eT>& /* unused */,
                const arma::Cube<eT>& gy,
                arma::Cube<eT>& g)
  {
    g = arma::zeros<arma::Cube<eT> >(inputParameter.n_rows,
        inputParameter.n_cols, inputParameter.n_slices);

    for (size_t s = 0; s < gy.n_slices; s++)
    {
      Unpooling(inputParameter.slice(s), gy.slice(s), g.slice(s));
    }
  }
开发者ID:shenzebang,项目名称:mlpack,代码行数:12,代码来源:pooling_layer.hpp


示例10: FeedBackward

  void FeedBackward(const arma::Cube<eT>& error)
  {
    delta = arma::zeros<arma::Cube<eT> >(inputLayer.InputActivation().n_rows,
                                         inputLayer.InputActivation().n_cols,
                                         inputLayer.InputActivation().n_slices);

    for (size_t outputmap = 0; outputmap < inputLayer.OutputMaps(); outputmap++)
    {
      for (size_t inputmap = 0; inputmap < outputLayer.OutputMaps(); inputmap++)
      {
        arma::Cube<eT> errorSlices = error.slices(inputmap *
            inputLayer.LayerSlices(), (inputmap * inputLayer.LayerSlices()) +
            inputLayer.LayerSlices() - 1);

        arma::Mat<eT> rotatedFilter;
        Rotate180(weights.slice(
            outputmap * outputLayer.OutputMaps() + inputmap), rotatedFilter);

        arma::Cube<eT> output;
        BackwardConvolutionRule::Convolution(errorSlices, rotatedFilter, output);

        delta.slices((outputmap * inputLayer.LayerSlices()),
            (outputmap * inputLayer.LayerSlices()) +
            inputLayer.LayerSlices() - 1) += output;
      }
    }
  }
开发者ID:suspy,项目名称:mlpack,代码行数:27,代码来源:conv_connection.hpp


示例11: Gradient

 void Gradient(const arma::Cube<eT>& d, InputDataType& g)
 {
   g = arma::Mat<eT>(weights.n_rows, weights.n_cols);
   for (size_t s = 0; s < d.n_slices; s++)
   {
     g(s) = arma::accu(d.slice(s)) * bias;
   }
 }
开发者ID:shenzebang,项目名称:mlpack,代码行数:8,代码来源:bias_layer.hpp


示例12: Forward

 void Forward(const arma::Cube<eT>& input, arma::Cube<eT>& output)
 {
   output = input;
   for (size_t s = 0; s < input.n_slices; s++)
   {
     output.slice(s) += weights(s) * bias;
   }
 }
开发者ID:shenzebang,项目名称:mlpack,代码行数:8,代码来源:bias_layer.hpp


示例13: FeedBackward

 void FeedBackward(const arma::Cube<eT>& error)
 {
   for (size_t s = 0; s < error.n_slices; s++)
   {
     Unpooling(inputLayer.InputActivation().slice(s), error.slice(s),
         delta.slice(s));
   }
 }
开发者ID:riveridea,项目名称:mlpack,代码行数:8,代码来源:pooling_connection.hpp


示例14: Convolution

  static void Convolution(const arma::Cube<eT>& input,
                          const arma::Mat<eT>& filter,
                          arma::Cube<eT>& output)
  {
    arma::Mat<eT> convOutput;
    SVDConvolution<BorderMode>::Convolution(input.slice(0), filter, convOutput);

    output = arma::Cube<eT>(convOutput.n_rows, convOutput.n_cols,
        input.n_slices);
    output.slice(0) = convOutput;

    for (size_t i = 1; i < input.n_slices; i++)
    {
      SVDConvolution<BorderMode>::Convolution(input.slice(i), filter,
          convOutput);
      output.slice(i) = convOutput;
    }
  }
开发者ID:sbrodehl,项目名称:mlpack,代码行数:18,代码来源:svd_convolution.hpp


示例15: Forward

void Forward(const arma::Cube<eT>& input, arma::Cube<eT>& output)
{
    const size_t wConv = ConvOutSize(input.n_rows, wfilter, xStride, wPad);
    const size_t hConv = ConvOutSize(input.n_cols, hfilter, yStride, hPad);

    output = arma::zeros<arma::Cube<eT> >(wConv, hConv, outMaps);
    for (size_t outMap = 0, outMapIdx = 0; outMap < outMaps; outMap++)
    {
        for (size_t inMap = 0; inMap < inMaps; inMap++, outMapIdx++)
        {
            arma::Mat<eT> convOutput;
            ForwardConvolutionRule::Convolution(input.slice(inMap),
                                                weights.slice(outMap), convOutput);

            output.slice(outMap) += convOutput;
        }
    }
}
开发者ID:shenzebang,项目名称:mlpack,代码行数:18,代码来源:conv_layer.hpp


示例16: TestArmadilloSerialization

void TestArmadilloSerialization(arma::Cube<CubeType>& x)
{
  // First save it.
  std::ofstream ofs("test", std::ios::binary);
  OArchiveType o(ofs);

  bool success = true;
  try
  {
    o << BOOST_SERIALIZATION_NVP(x);
  }
  catch (boost::archive::archive_exception& e)
  {
    success = false;
  }

  BOOST_REQUIRE_EQUAL(success, true);
  ofs.close();

  // Now load it.
  arma::Cube<CubeType> orig(x);
  success = true;
  std::ifstream ifs("test", std::ios::binary);
  IArchiveType i(ifs);

  try
  {
    i >> BOOST_SERIALIZATION_NVP(x);
  }
  catch (boost::archive::archive_exception& e)
  {
    success = false;
  }

  BOOST_REQUIRE_EQUAL(success, true);

  BOOST_REQUIRE_EQUAL(x.n_rows, orig.n_rows);
  BOOST_REQUIRE_EQUAL(x.n_cols, orig.n_cols);
  BOOST_REQUIRE_EQUAL(x.n_elem_slice, orig.n_elem_slice);
  BOOST_REQUIRE_EQUAL(x.n_slices, orig.n_slices);
  BOOST_REQUIRE_EQUAL(x.n_elem, orig.n_elem);
   
  for(size_t slice = 0; slice != x.n_slices; ++slice){
	auto const &orig_slice = orig.slice(slice);
	auto const &x_slice = x.slice(slice);
    for (size_t i = 0; i < x.n_cols; ++i){
      for (size_t j = 0; j < x.n_rows; ++j){
        if (double(orig_slice(j, i)) == 0.0)
          BOOST_REQUIRE_SMALL(double(x_slice(j, i)), 1e-8);
        else
          BOOST_REQUIRE_CLOSE(double(orig_slice(j, i)), double(x_slice(j, i)), 1e-8);
	  }
	}
  }

  remove("test");
}
开发者ID:Falit,项目名称:mlpack,代码行数:57,代码来源:serialization.hpp


示例17: Initialize

  void Initialize(arma::Cube<eT>& W,
                  const size_t rows,
                  const size_t cols,
                  const size_t slices)
  {
    W = arma::Cube<eT>(rows, cols, slices);

    for (size_t i = 0; i < slices; i++)
      Initialize(W.slice(i), rows, cols);
  }
开发者ID:vasanthkalingeri,项目名称:mlpack,代码行数:10,代码来源:kathirvalavakumar_subavathi_init.hpp


示例18: Convolution

  static void Convolution(const arma::Cube<eT>& input,
                          const arma::Mat<eT>& filter,
                          arma::Cube<eT>& output,
                          const size_t dW = 1,
                          const size_t dH = 1)
  {
    arma::Mat<eT> convOutput;
    NaiveConvolution<BorderMode>::Convolution(input.slice(0), filter,
        convOutput, dW, dH);

    output = arma::Cube<eT>(convOutput.n_rows, convOutput.n_cols,
        input.n_slices);
    output.slice(0) = convOutput;

    for (size_t i = 1; i < input.n_slices; i++)
    {
      NaiveConvolution<BorderMode>::Convolution(input.slice(i), filter,
          output.slice(i), dW, dH);
    }
  }
开发者ID:sbrodehl,项目名称:mlpack,代码行数:20,代码来源:naive_convolution.hpp


示例19: Gradient

void Gradient(const arma::Cube<eT>& d, arma::Cube<eT>& g)
{
    g = arma::zeros<arma::Cube<eT> >(weights.n_rows, weights.n_cols,
                                     weights.n_slices);

    for (size_t outMap = 0; outMap < outMaps; outMap++)
    {
        for (size_t inMap = 0, s = outMap; inMap < inMaps; inMap++, s += outMaps)
        {
            arma::Cube<eT> inputSlices = inputParameter.slices(inMap, inMap);
            arma::Cube<eT> deltaSlices = d.slices(outMap, outMap);

            arma::Cube<eT> output;
            GradientConvolutionRule::Convolution(inputSlices, deltaSlices, output);

            for (size_t i = 0; i < output.n_slices; i++)
                g.slice(s) += output.slice(i);
        }
    }
}
开发者ID:shenzebang,项目名称:mlpack,代码行数:20,代码来源:conv_layer.hpp


示例20: Backward

void Backward(const arma::Cube<eT>& /* unused */,
              const arma::Cube<eT>& gy,
              arma::Cube<eT>& g)
{
    g = arma::zeros<arma::Cube<eT> >(inputParameter.n_rows,
                                     inputParameter.n_cols,
                                     inputParameter.n_slices);

    for (size_t outMap = 0, outMapIdx = 0; outMap < inMaps; outMap++)
    {
        for (size_t inMap = 0; inMap < outMaps; inMap++, outMapIdx++)
        {
            arma::Mat<eT> rotatedFilter;
            Rotate180(weights.slice(outMap * outMaps + inMap), rotatedFilter);

            arma::Mat<eT> output;
            BackwardConvolutionRule::Convolution(gy.slice(inMap), rotatedFilter,
                                                 output);

            g.slice(outMap) += output;
        }
    }
}
开发者ID:shenzebang,项目名称:mlpack,代码行数:23,代码来源:conv_layer.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ arma::Mat类代码示例发布时间:2022-05-31
下一篇:
C++ arma::Col类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap