Skip to content

Commit 9f80e61

Browse files
authored
Update Neural Insights Getting Started documentation (#1127)
Signed-off-by: bmyrcha <bartosz.myrcha@intel.com>
1 parent 6ba7837 commit 9f80e61

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

neural_insights/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ pip install tensorflow
8888
# Prepare fp32 model
8989
wget https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_6/mobilenet_v1_1.0_224_frozen.pb
9090
```
91+
9192
```python
9293
from neural_compressor.config import PostTrainingQuantConfig
9394
from neural_compressor.data import DataLoader
9495
from neural_compressor.data import Datasets
9596
97+
top1 = Metric(name="topk", k=1)
9698
dataset = Datasets('tensorflow')['dummy'](shape=(1, 224, 224, 3))
9799
dataloader = DataLoader(framework='tensorflow', dataset=dataset)
98100
@@ -101,9 +103,15 @@ q_model = fit(
101103
model="./mobilenet_v1_1.0_224_frozen.pb",
102104
conf=PostTrainingQuantConfig(diagnosis=True),
103105
calib_dataloader=dataloader,
104-
eval_dataloader=dataloader)
106+
eval_dataloader=dataloader,
107+
eval_metric=top1
108+
)
105109
```
106110

111+
When the quantization is started, the workload should appear on the Neural Insights page and successively, new information should be available while quantization is in progress (such as weights distribution and accuracy data).
112+
113+
> Note that above example uses dummy data which is used to describe usage of Neural Insights. For diagnosis purposes you should use real dataset specific for your use case.
114+
107115
## Research Collaborations
108116

109117
Welcome to raise any interesting research ideas on model compression techniques and feel free to reach us (inc.maintainers@intel.com). Look forward to our collaborations on Neural Insights!

neural_insights/components/workload_manager/quantization_workload.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ def ratio(self) -> Optional[float]:
7070
Returns: accuracy ratio if baseline and optimized accuracy are present
7171
Otherwise returns None
7272
"""
73-
if self.optimized_accuracy is None or self.baseline_accuracy is None:
73+
if self.optimized_accuracy in [None, 0] or self.baseline_accuracy in [None, 0]:
7474
return None
75+
7576
return (self.optimized_accuracy - self.baseline_accuracy) / self.baseline_accuracy
7677

7778
def serialize(self, serialization_type: str = "default") -> Dict[str, Any]:

0 commit comments

Comments
 (0)