4 from onnx
import helper, shape_inference, optimizer
5 from onnx
import numpy_helper
6 from onnx
import AttributeProto, TensorProto, GraphProto
9 X = helper.make_tensor_value_info(
'X', TensorProto.FLOAT, [1, 1, 8, 8])
11 W_info = helper.make_tensor_value_info(
'W', TensorProto.FLOAT, [2, 1, 3, 3])
12 W = np.array([[[[-1,-1,-1],[-1,8,-1],[-1,-1,-1]]],[[[0,-1,0],[-1,5,-1],[0,-1,0]]]]).astype(np.float32)
13 W = numpy_helper.from_array(W,
'W')
17 Y = helper.make_tensor_value_info(
'Y', TensorProto.FLOAT, [1, 2, 8, 8])
19 conv1 = helper.make_node(
30 graph_def = helper.make_graph(
32 name=
'conv2d_a_model',
38 model_def = helper.make_model(graph_def, producer_name=
'benchmarks')
40 onnx.checker.check_model(model_def)
41 model_def = shape_inference.infer_shapes(model_def)
42 onnx.checker.check_model(model_def)
43 model_def = optimizer.optimize(model_def)
44 onnx.checker.check_model(model_def)
46 onnx.save_model(model_def,
'09_conv2d_a.onnx')