Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Nov 13th, 2018 97 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. import onnx
  2. from onnx.helper import make_node, make_graph, make_tensor, make_tensor_value_info, make_model
  3. import caffe2.python.onnx.backend as c2
  4.  
  5. import numpy as np
  6.  
  7. num = 1 * 256 * 56 * 56
  8. X = np.arange(num).reshape([1, 256, 56, 56]).astype(np.float32)
  9.  
  10. node_def = make_node(
  11.     'MaxPool',
  12.     inputs=['X'],
  13.     outputs=['Y'],
  14.     kernel_shape=[1, 1],
  15.     strides=[2,2],
  16.     pads=[0,0,0,0])
  17.  
  18. output = c2.run_node(
  19.         node_def, {"X": X})
  20. print("maxpool:")
  21. print(output.Y.shape)
  22. for i in range(10):
  23.     print(output.Y.flatten()[i])
  24.  
  25. W = np.full((256,1,1,1),1.0).astype(np.float32)
  26.  
  27. node_def = make_node(
  28.     'Conv',
  29.     inputs=['X', 'W'],
  30.     outputs=['Y'],
  31.     kernel_shape=[1, 1],
  32.     group=256,
  33.     pads=[0, 0, 0, 0],
  34.     strides=[2,2])
  35.  
  36. output = c2.run_node(
  37.         node_def, {"X": X, "W": W})
  38. print("conv:")
  39. print(output.Y.shape)
  40. for i in range(10):
  41.     print(output.Y.flatten()[i])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top