Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions examples/resnet/prepare_model_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import urllib.request
from pathlib import Path

import numpy as np
import torch
import torch.nn as nn
import torchvision
Expand Down Expand Up @@ -54,11 +55,15 @@ def update_lr(optimizer, lr):
param_group["lr"] = lr


def prepare_model(num_epochs=0, models_dir="models", data_dir="data"):
# seed everything to 0
def prepare_model(num_epochs=1, models_dir="models", data_dir="data"):
# seed everything to 0 for reproducibility, https://pytorch.org/docs/stable/notes/randomness.html
random.seed(0)
np.random.seed(0)
torch.manual_seed(0)
# the following are needed only for GPU
torch.cuda.manual_seed(0)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

Expand Down
2 changes: 1 addition & 1 deletion examples/resnet/resnet_ptq_cpu.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{
"name": "accuracy_custom",
"priority": 1, "higher_is_better": true,
"goal": {"type": "max-degradation", "value": 0.1}
"goal": {"type": "max-degradation", "value": 0.05}
}
],
"user_config":{
Expand Down
5 changes: 2 additions & 3 deletions examples/resnet/resnet_ptq_cpu_aml_dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{
"name": "accuracy_custom",
"priority": 1, "higher_is_better": true,
"goal": {"type": "max-degradation", "value": 0.01}
"goal": {"type": "max-degradation", "value": 0.05}
}
],
"user_config":{
Expand All @@ -52,7 +52,7 @@
{
"name": "avg",
"priority": 2,
"goal": {"type": "percent-min-improvement", "value": 20}
"goal": {"type": "percent-min-improvement", "value": 10}
}
],
"user_config":{
Expand Down Expand Up @@ -119,7 +119,6 @@
"evaluator": "common_evaluator",
"execution_providers": ["CPUExecutionProvider"],
"cache_dir": "cache",
"clean_cache": true,
"output_dir": "models/resnet_ptq_cpu"
}
}