Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.99 KB | None | 0 0
  1. File "/pythonpath/python3.7/site-packages/caffe/pycaffe.py", line 119, in _Net_forward
  2. outputs = set(self.outputs + blobs)
  3. TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32')
  4.  
  5. nn = caffe.Net('/model_path/model.prototxt',
  6. '/model_path/model.caffemodel',
  7. caffe.TEST)
  8.  
  9. WARNING: Logging before InitGoogleLogging() is written to STDERR
  10. W0423 14:53:15.663930 11914 _caffe.cpp:139] DEPRECATION WARNING - deprecated use of Python interface
  11. W0423 14:53:15.663944 11914 _caffe.cpp:140] Use this instead (with the named "weights" parameter):
  12. W0423 14:53:15.663946 11914 _caffe.cpp:142] Net('/path/model.prototxt', 1, weights='/path/model.caffemodel')
  13. I0423 14:53:15.665053 11914 net.cpp:51] Initializing net from parameters:
  14. state {
  15. phase: TEST
  16. level: 0
  17. }
  18. layer {
  19. name: "dense_1_input"
  20. type: "Input"
  21. top: "dense_1_input"
  22. input_param {
  23. shape {
  24. dim: 1
  25. dim: 40
  26. }
  27. }
  28. }
  29. .... more layers ...
  30. layer {
  31. name: "output_activation"
  32. type: "Softmax"
  33. bottom: "output"
  34. top: "output_activation"
  35. }
  36. I0423 14:53:15.665112 11914 layer_factory.hpp:77] Creating layer dense_1_input
  37. I0423 14:53:15.665118 11914 net.cpp:84] Creating Layer dense_1_input
  38. I0423 14:53:15.665122 11914 net.cpp:380] dense_1_input -> dense_1_input
  39. I0423 14:53:15.665140 11914 net.cpp:122] Setting up dense_1_input
  40. I0423 14:53:15.665143 11914 net.cpp:129] Top shape: 1 40 (40)
  41. I0423 14:53:15.665148 11914 net.cpp:137] Memory required for data: 160
  42. .... more layers ...
  43. I0423 14:53:15.665232 11914 layer_factory.hpp:77] Creating layer output_activation
  44. I0423 14:53:15.665236 11914 net.cpp:84] Creating Layer output_activation
  45. I0423 14:53:15.665239 11914 net.cpp:406] output_activation<- output
  46. I0423 14:53:15.665242 11914 net.cpp:380] output_activation-> output_activation
  47. I0423 14:53:15.665248 11914 net.cpp:122] Setting up output_activation
  48. I0423 14:53:15.665251 11914 net.cpp:129] Top shape: 1 3 (3)
  49. I0423 14:53:15.665254 11914 net.cpp:137] Memory required for data: 248
  50. I0423 14:53:15.665256 11914 net.cpp:200] output_activation does not need backward computation.
  51. .... more layers ...
  52. I0423 14:53:15.665269 11914 net.cpp:242] This network produces output output_activation
  53. I0423 14:53:15.665272 11914 net.cpp:255] Network initialization done.
  54.  
  55. # print data, its shape and type
  56. print("Data:")
  57. print(test_data)
  58. print("Data shape:")
  59. print(test_data.shape)
  60. print("Data type:")
  61. print(type(test_data))
  62. print("Type of array elements:")
  63. print(type(test_data[0][0]))
  64.  
  65.  
  66. # forward data through caffe model
  67. out = nn.forward(test_data)
  68. pred_probas = out['prob']
  69. print(pred_probas.argmax())
  70.  
  71. Data:
  72. [[ 0.2655475 0.2655475 0.2655475 0.2655475 0.2655475 0.26516597
  73. 0.26516597 0.26516597 0.26516597 0.26516597 -0.03401361 -0.04166667
  74. -0.03996599 -0.01870748 -0.01785714 -0.02636054 -0.0255102 -0.03401361
  75. -0.03231293 -0.0212585 0.02047792 0.02047792 0.02047792 0.02047792
  76. 0.02047792 0.02047792 0.02319407 0.02319407 0.02319407 0.02594073
  77. 0. 0. 0. 0. 0. 0.
  78. 0.01176471 0. 0. 0.01189689]]
  79. Data shape:
  80. (1, 40)
  81. Data type:
  82. <class 'numpy.ndarray'>
  83. Type of array elements:
  84. <class 'numpy.float64'>
  85.  
  86.  
  87. Traceback (most recent call last):
  88. File "/path/caffe_nn_test.py", line 41, in <module>
  89. out = nn.forward(test_data)
  90. File "//python3.7/site-packages/caffe/pycaffe.py", line 119, in _Net_forward
  91. outputs = set(self.outputs + blobs)
  92. TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32')
  93.  
  94. # load net from files
  95. nn = caffe.Net('/model_path/model.prototxt',
  96. '/model_path/model.caffemodel',
  97. caffe.TEST)
  98.  
  99. # test_data is a numpy array with the shape (1, 40)
  100.  
  101.  
  102. # set input for neural network
  103. nn.blobs['dense_1_input'] = test_data
  104.  
  105. # forward data through caffe model
  106. out = nn.forward(test_data)
  107.  
  108. # get class prediction
  109. pred_probas = out['prob']
  110. print(pred_probas.argmax())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement