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

1234567891011121314151617181920212223242526272829303132
  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. [TestMethod]
  17. public void Embedding()
  18. {
  19. var model = new Sequential();
  20. model.add(new Embedding(1000, 64, input_length: 10));
  21. // the model will take as input an integer matrix of size (batch,
  22. // input_length).
  23. // the largest integer (i.e. word index) in the input should be no larger
  24. // than 999 (vocabulary size).
  25. // now model.output_shape == (None, 10, 64), where None is the batch
  26. // dimension.
  27. var input_array = np.random.randint(1000, size: (32, 10));
  28. model.compile("rmsprop", "mse");
  29. }
  30. }
  31. }