[mlpack-svn] master: Add implementation of identity activation function. (7dad33e)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Wed Dec 31 15:50:04 EST 2014


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/0748e3c7b5776746cbd8a28850af0e21ebfccfa8...7dad33e2c2fd30e87e125ef826ae7ab652df8cf6

>---------------------------------------------------------------

commit 7dad33e2c2fd30e87e125ef826ae7ab652df8cf6
Author: Marcus Edel <marcus.edel at fu-berlin.de>
Date:   Wed Dec 31 21:49:45 2014 +0100

    Add implementation of identity activation function.


>---------------------------------------------------------------

7dad33e2c2fd30e87e125ef826ae7ab652df8cf6
 .../ann/activation_functions/identity_function.hpp | 76 ++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/src/mlpack/methods/ann/activation_functions/identity_function.hpp b/src/mlpack/methods/ann/activation_functions/identity_function.hpp
new file mode 100644
index 0000000..25dbd93
--- /dev/null
+++ b/src/mlpack/methods/ann/activation_functions/identity_function.hpp
@@ -0,0 +1,76 @@
+/**
+ * @file identity_function.hpp
+ * @author Marcus Edel
+ *
+ * Definition and implementation of the identity function.
+ */
+#ifndef __MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_IDENTITY_FUNCTION_HPP
+#define __MLPACK_METHODS_ANN_ACTIVATION_FUNCTIONS_IDENTITY_FUNCTION_HPP
+
+#include <mlpack/core.hpp>
+
+namespace mlpack {
+namespace ann /** Artificial Neural Network. */ {
+
+/**
+ * The identity function, defined by
+ *
+ * @f[
+ * f(x) &=& x \\
+ * f'(x) &=& 1
+ * @f]
+ */
+class IdentityFunction
+{
+ public:
+  /**
+   * Computes the identity function.
+   *
+   * @param x Input data.
+   * @return f(x).
+   */
+  static double fn(const double x)
+  {
+    return x;
+  }
+
+  /**
+   * Computes the identity function.
+   *
+   * @param x Input data.
+   * @param y The resulting output activation.
+   */
+  template<typename InputVecType, typename OutputVecType>
+  static void fn(const InputVecType& x, OutputVecType& y)
+  {
+    y = x;
+  }
+
+  /**
+   * Computes the first derivative of the identity function.
+   *
+   * @param x Input data.
+   * @return f'(x)
+   */
+  static double deriv(const double /* unused */)
+  {
+    return 1.0;
+  }
+
+  /**
+   * Computes the first derivatives of the identity function.
+   *
+   * @param y Input activations.
+   * @param x The resulting derivatives.
+   */
+  template<typename InputVecType, typename OutputVecType>
+  static void deriv(const InputVecType& y, OutputVecType& x)
+  {
+    x.ones(y.n_elem);
+  }
+}; // class IdentityFunction
+
+}; // namespace ann
+}; // namespace mlpack
+
+#endif




More information about the mlpack-svn mailing list