You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ClipTest.cs 808 B

123456789101112131415161718192021
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using static Tensorflow.Binding;
  3. using Tensorflow;
  4. namespace TensorFlowNET.UnitTest.ClipOps
  5. {
  6. [TestClass]
  7. public class ClipTest : EagerModeTestBase
  8. {
  9. [TestMethod]
  10. public void clip_by_global_norm()
  11. {
  12. var t_list = new Tensors(tf.constant(new float[] { 1, 2, 3, 4 }), tf.constant(new float[] { 5, 6, 7, 8 }));
  13. var clip_norm = .8f;
  14. var (res, norm) = tf.clip_by_global_norm(t_list, clip_norm);
  15. Equal(res[0].ToArray<float>(), new[] { 0.0560112074f, 0.112022415f, 0.16803363f, 0.22404483f });
  16. Equal(res[1].ToArray<float>(), new[] { 0.28005603f, 0.336067259f, 0.392078459f, 0.448089659f });
  17. Assert.AreEqual(norm.numpy(), 14.282857f);
  18. }
  19. }
  20. }