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


C++ NumericalDifferentiation::calculate_derivative方法代码示例

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


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

示例1: test_calculate_derivative

void NumericalDifferentiationTest::test_calculate_derivative(void)
{
   message += "test_calculate_derivative\n";

   NumericalDifferentiation nd;

//   double x;
   double d;

   // Test

   nd.set_numerical_differentiation_method(NumericalDifferentiation::ForwardDifferences);

//   x = 0.0;
   d = nd.calculate_derivative(*this, &NumericalDifferentiationTest::f1, 0.0);

   assert_true(d == 1.0, LOG);

   // Test

   nd.set_numerical_differentiation_method(NumericalDifferentiation::CentralDifferences);

//   x = 0.0;
   d = nd.calculate_derivative(*this, &NumericalDifferentiationTest::f1, 0.0);

   assert_true(d == 1.0, LOG);
}
开发者ID:petrarce,项目名称:MyNet,代码行数:27,代码来源:numerical_differentiation_test.cpp

示例2: test_calculate_derivatives

void UnscalingLayerTest::test_calculate_derivatives(void)
{
   message += "test_calculate_derivatives\n";

   NumericalDifferentiation nd;

   UnscalingLayer ul;

   ul.set_display(false);

   Vector<double> inputs;
   Vector<double> derivative;
   Vector<double> numerical_derivative;

   // Test

   ul.set(1);

   ul.set_unscaling_method(UnscalingLayer::MinimumMaximum);

   inputs.set(1, 0.0);

   derivative = ul.calculate_derivatives(inputs);

   assert_true(derivative == 1.0, LOG);

   // Test

   ul.set(1);

   ul.set_unscaling_method(UnscalingLayer::MeanStandardDeviation);

   inputs.set(1, 0.0);

   derivative = ul.calculate_derivatives(inputs);

   assert_true(derivative == 1.0, LOG);

   // Test

   if(numerical_differentiation_tests)
   {
      ul.set(3);

      ul.initialize_random();

      ul.set_unscaling_method(UnscalingLayer::MinimumMaximum);

      inputs.set(3);
      inputs.randomize_normal();

      derivative = ul.calculate_derivatives(inputs);
      numerical_derivative = nd.calculate_derivative(ul, &UnscalingLayer::calculate_outputs, inputs);

      assert_true((derivative-numerical_derivative).calculate_absolute_value() < 1.0e-3, LOG);
   }

   // Test

   if(numerical_differentiation_tests)
   {
      ul.set(3);

      ul.initialize_random();

      ul.set_unscaling_method(UnscalingLayer::MeanStandardDeviation);

      inputs.set(3);
      inputs.randomize_normal();

      derivative = ul.calculate_derivatives(inputs);
      numerical_derivative = nd.calculate_derivative(ul, &UnscalingLayer::calculate_outputs, inputs);

      assert_true((derivative-numerical_derivative).calculate_absolute_value() < 1.0e-3, LOG);
   }
}
开发者ID:Artelnics,项目名称:OpenNN,代码行数:76,代码来源:unscaling_layer_test.cpp


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