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.

CApiTest.cs 1.9 kB

6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using Tensorflow;
  6. namespace TensorFlowNET.UnitTest
  7. {
  8. public class CApiTest
  9. {
  10. protected TF_Code TF_OK = TF_Code.TF_OK;
  11. protected TF_DataType TF_FLOAT = TF_DataType.TF_FLOAT;
  12. protected void EXPECT_TRUE(bool expected)
  13. {
  14. Assert.IsTrue(expected);
  15. }
  16. protected void EXPECT_EQ(object expected, object actual)
  17. {
  18. Assert.AreEqual(expected, actual);
  19. }
  20. protected void ASSERT_EQ(object expected, object actual)
  21. {
  22. Assert.AreEqual(expected, actual);
  23. }
  24. protected void ASSERT_TRUE(bool condition)
  25. {
  26. Assert.IsTrue(condition);
  27. }
  28. protected OperationDescription TF_NewOperation(Graph graph, string opType, string opName)
  29. {
  30. return c_api.TF_NewOperation(graph, opType, opName);
  31. }
  32. protected void TF_AddInput(OperationDescription desc, TF_Output input)
  33. {
  34. c_api.TF_AddInput(desc, input);
  35. }
  36. protected Operation TF_FinishOperation(OperationDescription desc, Status s)
  37. {
  38. return c_api.TF_FinishOperation(desc, s);
  39. }
  40. protected void TF_SetAttrTensor(OperationDescription desc, string attrName, Tensor value, Status s)
  41. {
  42. c_api.TF_SetAttrTensor(desc, attrName, value, s);
  43. }
  44. protected void TF_SetAttrType(OperationDescription desc, string attrName, TF_DataType dtype)
  45. {
  46. c_api.TF_SetAttrType(desc, attrName, dtype);
  47. }
  48. protected void TF_SetAttrBool(OperationDescription desc, string attrName, bool value)
  49. {
  50. c_api.TF_SetAttrBool(desc, attrName, value);
  51. }
  52. protected TF_Code TF_GetCode(Status s)
  53. {
  54. return s.Code;
  55. }
  56. }
  57. }

tensorflow框架的.NET版本,提供了丰富的特性和API,可以借此很方便地在.NET平台下搭建深度学习训练与推理流程。