Skip to content

Commit fa13ff7

Browse files
authored
Add a new QKeras model (#6)
* Add a new QKeras model * Indent
1 parent d32b98e commit fa13ff7

5 files changed

+362
-2
lines changed

available_data_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"conv2d_small_mp_keras.onnx": {"example_data": false, "example_config": false}, "KERAS_conv1d.json": {"example_data": false, "example_config": false}, "three_layer_model.pt": {"example_data": false, "example_config": false}, "keras_bnn.json": {"example_data": false, "example_config": false}, "dense_big_keras.onnx": {"example_data": false, "example_config": false}, "KERAS_3layer_binary_smaller.json": {"example_data": false, "example_config": false}, "jetTagger_Conv2D_Small.json": {"example_data": false, "example_config": false}, "KERAS_3layer_binarydense_relu_max.json": {"example_data": false, "example_config": false}, "qkeras_3layer.json": {"example_data": false, "example_config": false}, "jetTagger_Conv2D_Small_NoBatchNorm.json": {"example_data": false, "example_config": false}, "KERAS_1layer.json": {"example_data": false, "example_config": false}, "3layer.pb": {"example_data": false, "example_config": false}, "KERAS_dense_16x200x200x200x200x200x5.json": {"example_data": false, "example_config": false}, "KERAS_3layer_batch_norm.json": {"example_data": false, "example_config": false}, "three_layer_keras.onnx": {"example_data": false, "example_config": false}, "KERAS_3layer.json": {"example_data": false, "example_config": false}, "conv2d_small_keras.onnx": {"example_data": false, "example_config": false}, "three_layer_bn_pytorch.onnx": {"example_data": false, "example_config": false}, "KERAS_dense_16x100x100x100x100x100x5.json": {"example_data": false, "example_config": false}, "KERAS_3layer_ternary_small.json": {"example_data": false, "example_config": false}, "KERAS_dense_16x500x500x500x500x500x5.json": {"example_data": false, "example_config": false}, "three_layer_bn_keras.onnx": {"example_data": false, "example_config": false}, "two_layer_keras.onnx": {"example_data": false, "example_config": false}, "garnet_3layer.json": {"example_data": false, "example_config": true}, "conv1d_small_keras.onnx": {"example_data": false, "example_config": false}, "KERAS_conv1d_small.json": {"example_data": false, "example_config": false}, "three_layer_pytorch.onnx": {"example_data": false, "example_config": false}, "two_layer_model.pt": {"example_data": false, "example_config": false}, "garnet_1layer.json": {"example_data": true, "example_config": true}, "two_layer_pytorch.onnx": {"example_data": false, "example_config": false}, "KERAS_conv2d_model.json": {"example_data": false, "example_config": false}}
1+
{"jetTagger_Conv2D_Small_NoBatchNorm.json": {"example_data": false, "example_config": false}, "qkeras_mnist_dense.json": {"example_data": false, "example_config": true}, "qkeras_3layer.json": {"example_data": false, "example_config": false}, "KERAS_3layer_binarydense_relu_max.json": {"example_data": false, "example_config": false}, "KERAS_3layer_ternary_small.json": {"example_data": false, "example_config": false}, "KERAS_dense_16x100x100x100x100x100x5.json": {"example_data": false, "example_config": false}, "KERAS_conv2d_model.json": {"example_data": false, "example_config": false}, "KERAS_dense_16x500x500x500x500x500x5.json": {"example_data": false, "example_config": false}, "KERAS_3layer.json": {"example_data": false, "example_config": false}, "KERAS_1layer.json": {"example_data": false, "example_config": false}, "KERAS_conv1d.json": {"example_data": false, "example_config": false}, "jetTagger_Conv2D_Small.json": {"example_data": false, "example_config": false}, "garnet_1layer.json": {"example_data": true, "example_config": true}, "KERAS_3layer_binary_smaller.json": {"example_data": false, "example_config": false}, "garnet_3layer.json": {"example_data": false, "example_config": true}, "KERAS_3layer_batch_norm.json": {"example_data": false, "example_config": false}, "keras_bnn.json": {"example_data": false, "example_config": false}, "KERAS_conv1d_small.json": {"example_data": false, "example_config": false}, "KERAS_dense_16x200x200x200x200x200x5.json": {"example_data": false, "example_config": false}, "two_layer_model.pt": {"example_data": false, "example_config": false}, "three_layer_model.pt": {"example_data": false, "example_config": false}, "two_layer_pytorch.onnx": {"example_data": false, "example_config": false}, "three_layer_bn_pytorch.onnx": {"example_data": false, "example_config": false}, "three_layer_keras.onnx": {"example_data": false, "example_config": false}, "conv2d_small_keras.onnx": {"example_data": false, "example_config": false}, "dense_big_keras.onnx": {"example_data": false, "example_config": false}, "conv1d_small_keras.onnx": {"example_data": false, "example_config": false}, "three_layer_bn_keras.onnx": {"example_data": false, "example_config": false}, "conv2d_small_mp_keras.onnx": {"example_data": false, "example_config": false}, "three_layer_pytorch.onnx": {"example_data": false, "example_config": false}, "two_layer_keras.onnx": {"example_data": false, "example_config": false}, "3layer.pb": {"example_data": false, "example_config": false}}

available_models.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"onnx": ["dense_big_keras.onnx", "conv2d_small_mp_keras.onnx", "two_layer_pytorch.onnx", "two_layer_keras.onnx", "three_layer_bn_keras.onnx", "conv1d_small_keras.onnx", "three_layer_pytorch.onnx", "three_layer_bn_pytorch.onnx", "three_layer_keras.onnx", "conv2d_small_keras.onnx"], "pytorch": ["two_layer_model.pt", "three_layer_model.pt"], "tensorflow": ["3layer.pb"], "keras": ["KERAS_3layer.json", "KERAS_dense_16x500x500x500x500x500x5.json", "KERAS_conv1d_small.json", "jetTagger_Conv2D_Small.json", "KERAS_3layer_ternary_small.json", "qkeras_3layer.json", "KERAS_dense_16x200x200x200x200x200x5.json", "keras_bnn.json", "garnet_1layer.json", "jetTagger_Conv2D_Small_NoBatchNorm.json", "garnet_3layer.json", "KERAS_3layer_binary_smaller.json", "KERAS_3layer_binarydense_relu_max.json", "KERAS_conv2d_model.json", "KERAS_dense_16x100x100x100x100x100x5.json", "KERAS_3layer_batch_norm.json", "KERAS_1layer.json", "KERAS_conv1d.json"]}
1+
{"keras": ["jetTagger_Conv2D_Small_NoBatchNorm.json", "qkeras_mnist_dense.json", "qkeras_3layer.json", "KERAS_3layer_binarydense_relu_max.json", "KERAS_3layer_ternary_small.json", "KERAS_dense_16x100x100x100x100x100x5.json", "KERAS_conv2d_model.json", "KERAS_dense_16x500x500x500x500x500x5.json", "KERAS_3layer.json", "KERAS_1layer.json", "KERAS_conv1d.json", "jetTagger_Conv2D_Small.json", "garnet_1layer.json", "KERAS_3layer_binary_smaller.json", "garnet_3layer.json", "KERAS_3layer_batch_norm.json", "keras_bnn.json", "KERAS_conv1d_small.json", "KERAS_dense_16x200x200x200x200x200x5.json"], "pytorch": ["two_layer_model.pt", "three_layer_model.pt"], "onnx": ["two_layer_pytorch.onnx", "three_layer_bn_pytorch.onnx", "three_layer_keras.onnx", "conv2d_small_keras.onnx", "dense_big_keras.onnx", "conv1d_small_keras.onnx", "three_layer_bn_keras.onnx", "conv2d_small_mp_keras.onnx", "three_layer_pytorch.onnx", "two_layer_keras.onnx"], "tensorflow": ["3layer.pb"]}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
KerasJson: qkeras_mnist_dense.json
2+
KerasH5: qkeras_mnist_dense_weights.h5
3+
OutputDir: qkeras_mnist_dense
4+
ProjectName: myproject
5+
XilinxPart: xcku115-flvb2104-2-i
6+
ClockPeriod: 5
7+
8+
IOType: io_parallel # options: io_serial/io_parallel
9+
10+
HLSConfig:
11+
Model:
12+
Precision: ap_fixed<16,6>
13+
ReuseFactor: 1
14+
Strategy: Resource
15+
LayerName:
16+
activation_3:
17+
Precision: ap_fixed<16,6>
18+
ReuseFactor: 1
19+
Strategy: Stable
20+
exp_table_t: ap_fixed<18,8,AP_RND,AP_SAT>
21+
inv_table_t: ap_fixed<18,8,AP_RND,AP_SAT>
22+
table_size: 1024
23+
input_3:
24+
Precision:
25+
result: ap_fixed<16,6>
26+
q_activation_2:
27+
Precision:
28+
result: ap_fixed<3,1>
29+
ReuseFactor: 1
30+
q_activation_3:
31+
Precision:
32+
result: ap_fixed<4,2>
33+
ReuseFactor: 1
34+
q_dense_2:
35+
Precision:
36+
bias: ap_fixed<3,1>
37+
weight: ap_int<5>
38+
ReuseFactor: 112
39+
q_dense_3:
40+
Precision:
41+
bias: ap_fixed<5,1>
42+
weight: ap_fixed<5,1>
43+
ReuseFactor: 1
44+
Strategy: Latency
45+

keras/qkeras_mnist_dense.json

Lines changed: 315 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,315 @@
1+
{
2+
"class_name": "Functional",
3+
"config": {
4+
"name": "functional_5",
5+
"layers": [
6+
{
7+
"class_name": "InputLayer",
8+
"config": {
9+
"batch_input_shape": [
10+
null,
11+
784
12+
],
13+
"dtype": "float32",
14+
"sparse": false,
15+
"ragged": false,
16+
"name": "input_3"
17+
},
18+
"name": "input_3",
19+
"inbound_nodes": []
20+
},
21+
{
22+
"class_name": "QActivation",
23+
"config": {
24+
"name": "q_activation_2",
25+
"trainable": true,
26+
"dtype": "float32",
27+
"activation": "quantized_relu(2)"
28+
},
29+
"name": "q_activation_2",
30+
"inbound_nodes": [
31+
[
32+
[
33+
"input_3",
34+
0,
35+
0,
36+
{}
37+
]
38+
]
39+
]
40+
},
41+
{
42+
"class_name": "QDense",
43+
"config": {
44+
"name": "q_dense_2",
45+
"trainable": true,
46+
"dtype": "float32",
47+
"units": 20,
48+
"activation": "linear",
49+
"use_bias": true,
50+
"kernel_initializer": {
51+
"class_name": "QInitializer",
52+
"config": {
53+
"initializer": {
54+
"class_name": "QInitializer",
55+
"config": {
56+
"initializer": {
57+
"class_name": "HeNormal",
58+
"config": {
59+
"seed": null
60+
},
61+
"__passive_serialization__": true
62+
},
63+
"use_scale": true,
64+
"quantizer": {
65+
"class_name": "quantized_po2",
66+
"config": {
67+
"bits": 4,
68+
"max_value": 1,
69+
"use_stochastic_rounding": false,
70+
"quadratic_approximation": false
71+
},
72+
"__passive_serialization__": true
73+
}
74+
},
75+
"__passive_serialization__": true
76+
},
77+
"use_scale": true,
78+
"quantizer": {
79+
"class_name": "quantized_po2",
80+
"config": {
81+
"bits": 4,
82+
"max_value": 1,
83+
"use_stochastic_rounding": false,
84+
"quadratic_approximation": false
85+
},
86+
"__passive_serialization__": true
87+
}
88+
}
89+
},
90+
"bias_initializer": {
91+
"class_name": "Zeros",
92+
"config": {}
93+
},
94+
"kernel_regularizer": null,
95+
"bias_regularizer": null,
96+
"activity_regularizer": null,
97+
"kernel_constraint": {
98+
"class_name": "Clip",
99+
"config": {
100+
"min_value": -1,
101+
"max_value": 1
102+
}
103+
},
104+
"bias_constraint": {
105+
"class_name": "Clip",
106+
"config": {
107+
"min_value": -1,
108+
"max_value": 1
109+
}
110+
},
111+
"kernel_quantizer": {
112+
"class_name": "quantized_po2",
113+
"config": {
114+
"bits": 4,
115+
"max_value": 1,
116+
"use_stochastic_rounding": false,
117+
"quadratic_approximation": false
118+
}
119+
},
120+
"bias_quantizer": {
121+
"class_name": "quantized_bits",
122+
"config": {
123+
"bits": 2,
124+
"integer": 0,
125+
"symmetric": 1,
126+
"alpha": null,
127+
"keep_negative": true,
128+
"use_stochastic_rounding": false
129+
}
130+
},
131+
"kernel_range": null,
132+
"bias_range": null
133+
},
134+
"name": "q_dense_2",
135+
"inbound_nodes": [
136+
[
137+
[
138+
"q_activation_2",
139+
0,
140+
0,
141+
{}
142+
]
143+
]
144+
]
145+
},
146+
{
147+
"class_name": "QActivation",
148+
"config": {
149+
"name": "q_activation_3",
150+
"trainable": true,
151+
"dtype": "float32",
152+
"activation": "quantized_relu(3,1)"
153+
},
154+
"name": "q_activation_3",
155+
"inbound_nodes": [
156+
[
157+
[
158+
"q_dense_2",
159+
0,
160+
0,
161+
{}
162+
]
163+
]
164+
]
165+
},
166+
{
167+
"class_name": "QDense",
168+
"config": {
169+
"name": "q_dense_3",
170+
"trainable": true,
171+
"dtype": "float32",
172+
"units": 10,
173+
"activation": "linear",
174+
"use_bias": true,
175+
"kernel_initializer": {
176+
"class_name": "QInitializer",
177+
"config": {
178+
"initializer": {
179+
"class_name": "QInitializer",
180+
"config": {
181+
"initializer": {
182+
"class_name": "HeNormal",
183+
"config": {
184+
"seed": null
185+
},
186+
"__passive_serialization__": true
187+
},
188+
"use_scale": true,
189+
"quantizer": {
190+
"class_name": "quantized_bits",
191+
"config": {
192+
"bits": 4,
193+
"integer": 0,
194+
"symmetric": 1,
195+
"alpha": 1,
196+
"keep_negative": true,
197+
"use_stochastic_rounding": false
198+
},
199+
"__passive_serialization__": true
200+
}
201+
},
202+
"__passive_serialization__": true
203+
},
204+
"use_scale": true,
205+
"quantizer": {
206+
"class_name": "quantized_bits",
207+
"config": {
208+
"bits": 4,
209+
"integer": 0,
210+
"symmetric": 1,
211+
"alpha": 1,
212+
"keep_negative": true,
213+
"use_stochastic_rounding": false
214+
},
215+
"__passive_serialization__": true
216+
}
217+
}
218+
},
219+
"bias_initializer": {
220+
"class_name": "Zeros",
221+
"config": {}
222+
},
223+
"kernel_regularizer": null,
224+
"bias_regularizer": null,
225+
"activity_regularizer": null,
226+
"kernel_constraint": {
227+
"class_name": "Clip",
228+
"config": {
229+
"min_value": -1,
230+
"max_value": 1
231+
}
232+
},
233+
"bias_constraint": {
234+
"class_name": "Clip",
235+
"config": {
236+
"min_value": -1,
237+
"max_value": 1
238+
}
239+
},
240+
"kernel_quantizer": {
241+
"class_name": "quantized_bits",
242+
"config": {
243+
"bits": 4,
244+
"integer": 0,
245+
"symmetric": 1,
246+
"alpha": 1,
247+
"keep_negative": true,
248+
"use_stochastic_rounding": false
249+
}
250+
},
251+
"bias_quantizer": {
252+
"class_name": "quantized_bits",
253+
"config": {
254+
"bits": 4,
255+
"integer": 0,
256+
"symmetric": 1,
257+
"alpha": null,
258+
"keep_negative": true,
259+
"use_stochastic_rounding": false
260+
}
261+
},
262+
"kernel_range": null,
263+
"bias_range": null
264+
},
265+
"name": "q_dense_3",
266+
"inbound_nodes": [
267+
[
268+
[
269+
"q_activation_3",
270+
0,
271+
0,
272+
{}
273+
]
274+
]
275+
]
276+
},
277+
{
278+
"class_name": "Activation",
279+
"config": {
280+
"name": "activation_3",
281+
"trainable": true,
282+
"dtype": "float32",
283+
"activation": "softmax"
284+
},
285+
"name": "activation_3",
286+
"inbound_nodes": [
287+
[
288+
[
289+
"q_dense_3",
290+
0,
291+
0,
292+
{}
293+
]
294+
]
295+
]
296+
}
297+
],
298+
"input_layers": [
299+
[
300+
"input_3",
301+
0,
302+
0
303+
]
304+
],
305+
"output_layers": [
306+
[
307+
"activation_3",
308+
0,
309+
0
310+
]
311+
]
312+
},
313+
"keras_version": "2.4.0",
314+
"backend": "tensorflow"
315+
}

keras/qkeras_mnist_dense_weights.h5

77.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)