nn_quantizer.py in ML examples is not working

Discussion related to "under the hood" OpenMV topics.
Sikandar
Posts: 4
Joined: Tue May 07, 2019 9:14 am

nn_quantizer.py in ML examples is not working

Postby Sikandar » Wed May 08, 2019 5:35 am

Hi, I have trained my CNN on the MNIST dataset (LeNet). However, in the quantization step, the script breaks at line 232 with index out of range error. I would appreciate any help.
User avatar
iabdalkader
Posts: 1143
Joined: Sun May 24, 2015 3:53 pm

Re: nn_quantizer.py in ML examples is not working

Postby iabdalkader » Wed May 08, 2019 8:41 am

Hi, yes I saw your post, will test it and get back to you.
Sikandar
Posts: 4
Joined: Tue May 07, 2019 9:14 am

Re: nn_quantizer.py in ML examples is not working

Postby Sikandar » Wed May 08, 2019 11:19 am

Thank you, iabdalkader

Error:

Code: Select all

current_blob = self.bottom_blob[current_layer][0]
IndexError: list index out of range
my model.prototxt

Code: Select all

name: "Siknet"
layer {
  name: "mnist"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "examples/mnist/mnist_train_lmdb"
    batch_size: 64
    backend: LMDB
  }
}
layer {
  name: "mnist"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "examples/mnist/mnist_test_lmdb"
    batch_size: 100
    backend: LMDB
  }
}
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 20
    pad: 2
    kernel_size: 5
    stride: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "pool1"
  type: "Pooling"
  bottom: "conv1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}
layer {
  name: "conv2"
  type: "Convolution"
  bottom: "pool1"
  top: "conv2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 48
    pad: 2
    kernel_size: 5
    stride: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "pool2"
  type: "Pooling"
  bottom: "conv2"
  top: "pool2"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}
layer {
  name: "ip1"
  type: "InnerProduct"
  bottom: "pool2"
  top: "ip1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 128
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "ip1"
  top: "ip1"
}
layer {
  name: "ip2"
  type: "InnerProduct"
  bottom: "ip1"
  top: "ip2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 10
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "ip2"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "ip2"
  bottom: "label"
  top: "loss"
}
User avatar
iabdalkader
Posts: 1143
Joined: Sun May 24, 2015 3:53 pm

Re: nn_quantizer.py in ML examples is not working

Postby iabdalkader » Wed May 08, 2019 7:01 pm

Hi, for some reason data layers need to be named "data" this must be a bug, anyway if you change the name back to "data" it works.

Code: Select all

  name: "data"
Sikandar
Posts: 4
Joined: Tue May 07, 2019 9:14 am

Re: nn_quantizer.py in ML examples is not working

Postby Sikandar » Thu May 09, 2019 3:37 am

Thank you for your help. I saw that the cifar10 example is the most extensively documented, so I suspected that the script might have been written with its model in mind. So when I trained my data with that model the script ran fine.
I will now try your solution with my own model.

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 6 guests