Skip to content

Commit f141aff

Browse files
notebook example fix model url and adapt to inc api (#1519)
1 parent e884f54 commit f141aff

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

examples/notebook/tensorflow/vgg19_ibean/inc_quantize_vgg19.ipynb

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
"outputs": [],
162162
"source": [
163163
"def build_model(w, h, class_num):\n",
164-
" url = 'https://tfhub.dev/deepmind/ganeval-cifar10-convnet/1'\n",
164+
" url = \"https://www.kaggle.com/models/deepmind/ganeval-cifar10-convnet/frameworks/TensorFlow1/variations/ganeval-cifar10-convnet/versions/1\"\n",
165165
" feature_extractor_layer = hub.KerasLayer(url, input_shape = (w, h, 3))\n",
166166
" feature_extractor_layer.trainable = False\n",
167167
"\n",
@@ -421,6 +421,8 @@
421421
"from neural_compressor.data import DataLoader\n",
422422
"from neural_compressor.quantization import fit\n",
423423
"from neural_compressor.config import PostTrainingQuantConfig, AccuracyCriterion\n",
424+
"from neural_compressor import Metric\n",
425+
"\n",
424426
"\n",
425427
"def auto_tune(input_graph_path, batch_size, int8_pb_file):\n",
426428
" dataset = Dataset()\n",
@@ -434,11 +436,15 @@
434436
" tolerable_loss=0.01 \n",
435437
" )\n",
436438
" )\n",
439+
"\n",
440+
" top1 = Metric(name=\"topk\", k=1)\n",
441+
" \n",
437442
" q_model = fit(\n",
438443
" model=input_graph_path,\n",
439444
" conf=config,\n",
440445
" calib_dataloader=dataloader,\n",
441-
" eval_dataloader=dataloader\n",
446+
" eval_dataloader=dataloader,\n",
447+
" eval_metric=top1\n",
442448
" )\n",
443449
"\n",
444450
" return q_model\n",
@@ -588,6 +594,24 @@
588594
"}\n",
589595
"```"
590596
]
597+
},
598+
{
599+
"cell_type": "code",
600+
"execution_count": null,
601+
"id": "e0fbd1da-2731-4398-a327-9908c87c8c5f",
602+
"metadata": {},
603+
"outputs": [],
604+
"source": [
605+
"!which python "
606+
]
607+
},
608+
{
609+
"cell_type": "code",
610+
"execution_count": null,
611+
"id": "ae14f078-3414-45c5-bb98-b77eb33c0070",
612+
"metadata": {},
613+
"outputs": [],
614+
"source": []
591615
}
592616
],
593617
"metadata": {
@@ -606,7 +630,7 @@
606630
"name": "python",
607631
"nbconvert_exporter": "python",
608632
"pygments_lexer": "ipython3",
609-
"version": "3.9.15"
633+
"version": "3.9.18"
610634
}
611635
},
612636
"nbformat": 4,

0 commit comments

Comments
 (0)