Skip to content

Commit

Permalink
notebook example fix model url and adapt to inc api (#1519)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoZhangJianyu authored Jan 15, 2024
1 parent e884f54 commit f141aff
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions examples/notebook/tensorflow/vgg19_ibean/inc_quantize_vgg19.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"outputs": [],
"source": [
"def build_model(w, h, class_num):\n",
" url = 'https://tfhub.dev/deepmind/ganeval-cifar10-convnet/1'\n",
" url = \"https://www.kaggle.com/models/deepmind/ganeval-cifar10-convnet/frameworks/TensorFlow1/variations/ganeval-cifar10-convnet/versions/1\"\n",
" feature_extractor_layer = hub.KerasLayer(url, input_shape = (w, h, 3))\n",
" feature_extractor_layer.trainable = False\n",
"\n",
Expand Down Expand Up @@ -421,6 +421,8 @@
"from neural_compressor.data import DataLoader\n",
"from neural_compressor.quantization import fit\n",
"from neural_compressor.config import PostTrainingQuantConfig, AccuracyCriterion\n",
"from neural_compressor import Metric\n",
"\n",
"\n",
"def auto_tune(input_graph_path, batch_size, int8_pb_file):\n",
" dataset = Dataset()\n",
Expand All @@ -434,11 +436,15 @@
" tolerable_loss=0.01 \n",
" )\n",
" )\n",
"\n",
" top1 = Metric(name=\"topk\", k=1)\n",
" \n",
" q_model = fit(\n",
" model=input_graph_path,\n",
" conf=config,\n",
" calib_dataloader=dataloader,\n",
" eval_dataloader=dataloader\n",
" eval_dataloader=dataloader,\n",
" eval_metric=top1\n",
" )\n",
"\n",
" return q_model\n",
Expand Down Expand Up @@ -588,6 +594,24 @@
"}\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e0fbd1da-2731-4398-a327-9908c87c8c5f",
"metadata": {},
"outputs": [],
"source": [
"!which python "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ae14f078-3414-45c5-bb98-b77eb33c0070",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -606,7 +630,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
"version": "3.9.18"
}
},
"nbformat": 4,
Expand Down

0 comments on commit f141aff

Please sign in to comment.