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.1 kB

123456789101112131415161718192021222324252627282930313233
  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. namespace TensorFlowNET.UnitTest.Keras
  9. {
  10. /// <summary>
  11. /// https://www.tensorflow.org/versions/r1.14/api_docs/python/tf/keras/layers/Embedding
  12. /// </summary>
  13. [TestClass]
  14. public class EmbeddingTest
  15. {
  16. [Ignore]
  17. [TestMethod]
  18. public void Embedding()
  19. {
  20. var model = new Sequential();
  21. model.add(new Embedding(1000, 64, input_length: 10));
  22. // the model will take as input an integer matrix of size (batch,
  23. // input_length).
  24. // the largest integer (i.e. word index) in the input should be no larger
  25. // than 999 (vocabulary size).
  26. // now model.output_shape == (None, 10, 64), where None is the batch
  27. // dimension.
  28. var input_array = np.random.randint(1000, size: (32, 10));
  29. model.compile("rmsprop", "mse");
  30. }
  31. }
  32. }