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.

param-and-model-file-structure.md 2.6 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ## net.param
  2. ### example
  3. ```
  4. 7767517
  5. 3 3
  6. Input input 0 1 data 0=4 1=4 2=1
  7. InnerProduct ip 1 1 data fc 0=10 1=1 2=80
  8. Softmax softmax 1 1 fc prob 0=0
  9. ```
  10. ### overview
  11. ```
  12. [magic]
  13. ```
  14. * magic number : 7767517
  15. ```
  16. [layer count] [blob count]
  17. ```
  18. * layer count : count of the layer line follows, should be exactly the count of all layer names
  19. * blob count : count of all blobs, usually greater than or equals to the layer count
  20. ### layer line
  21. ```
  22. [layer type] [layer name] [input count] [output count] [input blobs] [output blobs] [layer specific params]
  23. ```
  24. * layer type : type name, such as Convolution Softmax etc
  25. * layer name : name of this layer, must be unique among all layer names
  26. * input count : count of the blobs this layer needs as input
  27. * output count : count of the blobs this layer produces as output
  28. * input blobs : name list of all the input blob names, seperated by space, must be unique among input blob names of all layers
  29. * output blobs : name list of all the output blob names, seperated by space, must be unique among output blob names of all layers
  30. * layer specific params : key=value pair list, seperated by space
  31. ### layer param
  32. ```
  33. 0=1 1=2.5 -23303=2,2.0,3.0
  34. ```
  35. key index should be unique in each layer line, pair can be omitted if the default value used
  36. the meaning of existing param key index can be looked up at [operation-param-weight-table](operation-param-weight-table)
  37. * integer or float key : index 0 ~ 19
  38. * integer value : int
  39. * float value : float
  40. * integer array or float array key : -23300 minus index 0 ~ 19
  41. * integer array value : [array size],int,int,...,int
  42. * float array value : [array size],float,float,...,float
  43. ## net.bin
  44. ```
  45. +---------+---------+---------+---------+---------+---------+
  46. | weight1 | weight2 | weight3 | weight4 | ....... | weightN |
  47. +---------+---------+---------+---------+---------+---------+
  48. ^ ^ ^ ^
  49. 0x0 0x80 0x140 0x1C0
  50. ```
  51. the model binary is the concatenation of all weight data, each weight buffer is aligned by 32bit
  52. ### weight buffer
  53. ```
  54. [flag] (optional)
  55. [raw data]
  56. [padding] (optional)
  57. ```
  58. * flag : unsigned int, little-endian, indicating the weight storage type, 0 => float32, 0x01306B47 => float16, otherwise => quantized int8, may be omitted if the layer implementation forced the storage type explicitly
  59. * raw data : raw weight data, little-endian, float32 data or float16 data or quantized table and indexes depending on the storage type flag
  60. * padding : padding space for 32bit alignment, may be omitted if already aligned