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.

Rnn.Test.cs 930 B

12345678910111213141516171819202122232425262728
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Tensorflow.NumPy;
  8. using static Tensorflow.Binding;
  9. namespace Tensorflow.Keras.UnitTest.Layers
  10. {
  11. [TestClass]
  12. public class Rnn
  13. {
  14. [TestMethod]
  15. public void SimpleRNN()
  16. {
  17. var inputs = np.arange(6 * 10 * 8).reshape((6, 10, 8)).astype(np.float32);
  18. /*var simple_rnn = keras.layers.SimpleRNN(4);
  19. var output = simple_rnn.Apply(inputs);
  20. Assert.AreEqual((32, 4), output.shape);*/
  21. var simple_rnn = tf.keras.layers.SimpleRNN(4, return_sequences: true, return_state: true);
  22. var (whole_sequence_output, final_state) = simple_rnn.Apply(inputs);
  23. Console.WriteLine(whole_sequence_output);
  24. Console.WriteLine(final_state);
  25. }
  26. }
  27. }