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.

EmbeddingTest.cs 1.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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/r1.14/api_docs/python/tf/keras/layers/Embedding
  14. /// </summary>
  15. [TestClass, Ignore]
  16. public class EmbeddingTest : GraphModeTestBase
  17. {
  18. [TestMethod]
  19. public void Embedding()
  20. {
  21. var model = new Sequential();
  22. model.add(new Embedding(1000, 64, input_length: 10));
  23. // the model will take as input an integer matrix of size (batch,
  24. // input_length).
  25. // the largest integer (i.e. word index) in the input should be no larger
  26. // than 999 (vocabulary size).
  27. // now model.output_shape == (None, 10, 64), where None is the batch
  28. // dimension.
  29. var input_array = np.random.randint(1000, size: (32, 10));
  30. model.compile("rmsprop", "mse");
  31. }
  32. [TestMethod]
  33. public void Dense()
  34. {
  35. var model = tf.keras.Sequential();
  36. var dense_layer = tf.keras.layers.Dense(5, input_shape: 3);
  37. model.add(dense_layer);
  38. }
  39. }
  40. }