Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/marian.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Junczys-Dowmunt <junczys@amu.edu.pl>2017-02-13 18:59:09 +0300
committerMarcin Junczys-Dowmunt <junczys@amu.edu.pl>2017-02-13 18:59:09 +0300
commitab6850446471c61e1d1cc262321b5dc4a797a6ef (patch)
tree8e43a820b4ec003ad037a2268ea8e5724b027bd5 /src/graph/node_operators_unary.h
parente74567948a8bd21424d02c767cda627214127edf (diff)
batch normalization
Diffstat (limited to 'src/graph/node_operators_unary.h')
-rw-r--r--src/graph/node_operators_unary.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/graph/node_operators_unary.h b/src/graph/node_operators_unary.h
index f58df3bc..5a6da1b4 100644
--- a/src/graph/node_operators_unary.h
+++ b/src/graph/node_operators_unary.h
@@ -423,6 +423,40 @@ struct ExpNodeOp : public UnaryNodeOp {
};
+struct PowNodeOp : public UnaryNodeOp {
+ float exponent_;
+ float epsilon_;
+
+ template <typename ...Args>
+ PowNodeOp(Expr a, float exponent, float epsilon, Args ...args)
+ : UnaryNodeOp(a, args...),
+ exponent_(exponent),
+ epsilon_(epsilon) { }
+
+ NodeOps forwardOps() {
+ return {
+ NodeOp(Element(_1 = Pow(epsilon_ + _2, exponent_),
+ val_,
+ children_[0]->val()))
+ };
+ }
+
+ NodeOps backwardOps() {
+ return {
+ NodeOp(Add(exponent_ * Pow(epsilon_ + _1, exponent_ - 1.f) * _2,
+ children_[0]->grad(),
+ children_[0]->val(),
+ adj_))
+ };
+ }
+
+ const std::string type() {
+ return "pow";
+ }
+
+};
+
+
struct NegNodeOp : public UnaryNodeOp {
template <typename ...Args>
NegNodeOp(Args ...args)