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.

ModelSaveTest.cs 969 B

12345678910111213141516171819202122232425262728293031323334353637
  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/guide/keras/save_and_serialize
  14. /// </summary>
  15. [TestClass]
  16. public class ModelSaveTest : EagerModeTestBase
  17. {
  18. [TestMethod]
  19. public void SaveAndLoadTest()
  20. {
  21. var model = GetModel();
  22. }
  23. Model GetModel()
  24. {
  25. var keras = tf.keras;
  26. // Create a simple model.
  27. var inputs = keras.Input(shape: 32);
  28. var outputs = keras.layers.Dense(1).Apply(inputs);
  29. var model = keras.Model(inputs, outputs);
  30. model.compile("adam", "mean_squared_error");
  31. return model;
  32. }
  33. }
  34. }