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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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_EQ(object expected, object actual)
  13. {
  14. Assert.AreEqual(expected, actual);
  15. }
  16. protected void ASSERT_EQ(object expected, object actual)
  17. {
  18. Assert.AreEqual(expected, actual);
  19. }
  20. protected void ASSERT_TRUE(bool condition)
  21. {
  22. Assert.IsTrue(condition);
  23. }
  24. protected OperationDescription TF_NewOperation(Graph graph, string opType, string opName)
  25. {
  26. return c_api.TF_NewOperation(graph, opType, opName);
  27. }
  28. protected void TF_AddInput(OperationDescription desc, TF_Output input)
  29. {
  30. c_api.TF_AddInput(desc, input);
  31. }
  32. protected Operation TF_FinishOperation(OperationDescription desc, Status s)
  33. {
  34. return c_api.TF_FinishOperation(desc, s);
  35. }
  36. protected void TF_SetAttrTensor(OperationDescription desc, string attrName, Tensor value, Status s)
  37. {
  38. c_api.TF_SetAttrTensor(desc, attrName, value, s);
  39. }
  40. protected void TF_SetAttrType(OperationDescription desc, string attrName, TF_DataType dtype)
  41. {
  42. c_api.TF_SetAttrType(desc, attrName, dtype);
  43. }
  44. protected void TF_SetAttrBool(OperationDescription desc, string attrName, bool value)
  45. {
  46. c_api.TF_SetAttrBool(desc, attrName, value);
  47. }
  48. protected TF_Code TF_GetCode(Status s)
  49. {
  50. return s.Code;
  51. }
  52. }
  53. }

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