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.

LayersTest.cs 1.6 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using Tensorflow.Keras.Engine;
  6. using Tensorflow.Keras.Layers;
  7. using NumSharp;
  8. using Tensorflow.UnitTest;
  9. using static Tensorflow.Binding;
  10. namespace TensorFlowNET.UnitTest.Keras
  11. {
  12. /// <summary>
  13. /// https://www.tensorflow.org/versions/r2.3/api_docs/python/tf/keras/layers
  14. /// </summary>
  15. [TestClass, Ignore]
  16. public class LayersTest : GraphModeTestBase
  17. {
  18. [TestMethod]
  19. public void Sequential()
  20. {
  21. var model = tf.keras.models.Sequential();
  22. model.add(tf.keras.Input(shape: 16));
  23. }
  24. [TestMethod]
  25. public void Embedding()
  26. {
  27. var model = new Sequential();
  28. model.add(new Embedding(1000, 64, input_length: 10));
  29. // the model will take as input an integer matrix of size (batch,
  30. // input_length).
  31. // the largest integer (i.e. word index) in the input should be no larger
  32. // than 999 (vocabulary size).
  33. // now model.output_shape == (None, 10, 64), where None is the batch
  34. // dimension.
  35. var input_array = np.random.randint(1000, size: (32, 10));
  36. model.compile("rmsprop", "mse");
  37. }
  38. [TestMethod]
  39. public void Dense()
  40. {
  41. var model = tf.keras.Sequential();
  42. var dense_layer = tf.keras.layers.Dense(5, input_shape: 3);
  43. model.add(dense_layer);
  44. }
  45. }
  46. }