#
# Copyright (c) 2021 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: 1.0

model:
  name: imagenet_prune
  framework: pytorch

pruning:
  train:
    start_epoch: 0
    end_epoch: 5
    iteration: 20
    dataloader:
      batch_size: 256
      shuffle: True
      dataset:
        ImageFolder:
          root: /path/to/imagenet/train              # NOTE: modify to your training dataset location if needed
      transform:
        RandomResizedCrop:
          size: 224
        RandomHorizontalFlip: {}
        ToTensor: {}
        Normalize:
          mean: [0.485, 0.456, 0.406]
          std: [0.229, 0.224, 0.225]

    optimizer:
      SGD:
        learning_rate: 0.0001
    criterion:
      CrossEntropyLoss:
  approach:
    weight_compression:
      initial_sparsity: 0.0
      target_sparsity: 0.3
      start_epoch: 0
      end_epoch: 4
      pruners:
        - !Pruner
            start_epoch: 0
            end_epoch: 4
            update_frequency: 1
            prune_type: basic_magnitude
            names: ['layer1.0.conv1.weight', 'layer1.0.conv2.weight']

evaluation:                                          # optional. required if user doesn't provide eval_func in neural_compressor.Quantization.
  accuracy:                                          # optional. required if user doesn't provide eval_func in neural_compressor.Quantization.
    metric:
      topk: 1                                        # built-in metrics are topk, map, f1, allow user to register new metric.
    dataloader:
      batch_size: 256
      dataset:
        ImageFolder:
          root: /path/to/imagenet/val                # NOTE: modify to your evaluation dataset location if needed
      transform:
        Resize:
          size: 256
        CenterCrop:
          size: 224
        ToTensor: {}
        Normalize:
          mean: [0.485, 0.456, 0.406]
          std: [0.229, 0.224, 0.225]

tuning:
  accuracy_criterion:
    relative: 0.01                             # the tuning target of accuracy loss percentage: 1%
  exit_policy:
    timeout: 0                                   # tuning timeout (seconds)
  random_seed: 9527                            # random seed
