aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/ops/training_ops_test.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-11-17 12:08:27 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-11-17 12:12:49 -0800
commit9dd9246d76aeada08f07d8c9550d7eedb0809713 (patch)
treef0be65b1a599620e0264573e6107dbec8b2be951 /tensorflow/core/ops/training_ops_test.cc
parentb8bef6e6c89931768ac1f6b28d834d359e761410 (diff)
Open-sourcing AddSign and PowerSign optimizers, found in Neural Optimizer
Search with Reinforcement Learning [Bello et al, ICML2017] PiperOrigin-RevId: 176142062
Diffstat (limited to 'tensorflow/core/ops/training_ops_test.cc')
-rw-r--r--tensorflow/core/ops/training_ops_test.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/tensorflow/core/ops/training_ops_test.cc b/tensorflow/core/ops/training_ops_test.cc
index 92d5ad9964..de4e3cd9e7 100644
--- a/tensorflow/core/ops/training_ops_test.cc
+++ b/tensorflow/core/ops/training_ops_test.cc
@@ -332,4 +332,38 @@ TEST(TrainingOpsTest, SparseApplyRMSProp_ShapeFn) {
INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;?;[?];?;?");
}
+TEST(TrainingOpsTest, ApplyAddSign_ShapeFn) {
+ ShapeInferenceTestOp op("ApplyAddSign");
+
+ // Output is a merge of inputs 0, 1, and 6 (var, ms, and grad).
+ INFER_OK(op, "[1,?,?];[?,2,?];[];[];[];[];[?,?,2]", "[d0_0,d1_1,d6_2]");
+ INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
+ "[1];[2];[];[];[];[];[1]");
+ INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
+ "[1];[1];[];[];[];[];[2]");
+
+ // lr, alpha, sign_decay, and beta must be scalars.
+ INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;[?];?;?;?;?");
+ INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;[?];?;?;?");
+ INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;[?];?;?");
+ INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;[?];?");
+}
+
+TEST(TrainingOpsTest, ApplyPowerSign_ShapeFn) {
+ ShapeInferenceTestOp op("ApplyPowerSign");
+
+ // Output is a merge of inputs 0, 1, and 6 (var, ms, and grad).
+ INFER_OK(op, "[1,?,?];[?,2,?];[];[];[];[];[?,?,2]", "[d0_0,d1_1,d6_2]");
+ INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
+ "[1];[2];[];[];[];[];[1]");
+ INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
+ "[1];[1];[];[];[];[];[2]");
+
+ // lr, logbase, sign_decay, and beta must be scalars.
+ INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;[?];?;?;?;?");
+ INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;[?];?;?;?");
+ INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;[?];?;?");
+ INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;[?];?");
+}
+
} // end namespace tensorflow