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.

SimpleRnnTest.cs 821 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Tensorflow.Keras;
  5. using Tensorflow.NumPy;
  6. using static Tensorflow.Binding;
  7. using static Tensorflow.KerasApi;
  8. namespace Tensorflow
  9. {
  10. public class SimpleRnnTest
  11. {
  12. public void Run()
  13. {
  14. var inputs = np.random.random((6, 10, 8)).astype(np.float32);
  15. //var simple_rnn = tf.keras.layers.SimpleRNN(4);
  16. //var output = simple_rnn.Apply(inputs); // The output has shape `[32, 4]`.
  17. var simple_rnn = tf.keras.layers.SimpleRNN(4, return_sequences: true, return_state: true);
  18. // whole_sequence_output has shape `[32, 10, 4]`.
  19. // final_state has shape `[32, 4]`.
  20. var (whole_sequence_output, final_states) = simple_rnn.Apply(inputs);
  21. }
  22. }
  23. }