| @@ -157,6 +157,9 @@ namespace Tensorflow | |||||
| }); | }); | ||||
| } | } | ||||
| public Tensor l2_loss(Tensor t, string name = null) | |||||
| => nn_ops.l2_loss(t, name: name); | |||||
| /// <summary> | /// <summary> | ||||
| /// Local Response Normalization. | /// Local Response Normalization. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -128,6 +128,9 @@ namespace Tensorflow | |||||
| return _softmax(logits, gen_nn_ops.softmax, axis, name); | return _softmax(logits, gen_nn_ops.softmax, axis, name); | ||||
| } | } | ||||
| public static Tensor l2_loss(Tensor t, string name = null) | |||||
| => tf.Context.ExecuteOp("L2Loss", name, new ExecuteOpArgs(t)); | |||||
| public static Tensor leaky_relu(Tensor features, float alpha = 0.2f, string name = null) | public static Tensor leaky_relu(Tensor features, float alpha = 0.2f, string name = null) | ||||
| { | { | ||||
| return tf_with(ops.name_scope(name, "LeakyRelu", new { features, alpha }), scope => | return tf_with(ops.name_scope(name, "LeakyRelu", new { features, alpha }), scope => | ||||
| @@ -2,7 +2,7 @@ | |||||
| using Tensorflow; | using Tensorflow; | ||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| namespace TensorFlowNET.UnitTest.nn_test | |||||
| namespace TensorFlowNET.UnitTest.NenuralNetwork | |||||
| { | { | ||||
| [TestClass] | [TestClass] | ||||
| public class ActivationFunctionTest : EagerModeTestBase | public class ActivationFunctionTest : EagerModeTestBase | ||||
| @@ -0,0 +1,18 @@ | |||||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | |||||
| using static Tensorflow.Binding; | |||||
| using Tensorflow.NumPy; | |||||
| namespace TensorFlowNET.UnitTest.NenuralNetwork | |||||
| { | |||||
| [TestClass] | |||||
| public class NeuralNetworkTest : EagerModeTestBase | |||||
| { | |||||
| [TestMethod] | |||||
| public void l2_loss() | |||||
| { | |||||
| var x = tf.Variable(np.array(new[,] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 } }), dtype: tf.float32); | |||||
| var l2 = tf.nn.l2_loss(x); | |||||
| Assert.AreEqual(l2.numpy(), 102f); | |||||
| } | |||||
| } | |||||
| } | |||||