Skip to content
Snippets Groups Projects
Commit a39ad20d authored by Hashim Sharif's avatar Hashim Sharif
Browse files

Adding python script for reading quantization ranges from trained weights

parent 209bf7a4
No related branches found
No related tags found
No related merge requests found
import numpy as np
import os
import struct
def read_value_range(file_name):
print file_name
f = open(file_name, "rb")
bytes = os.stat(file_name).st_size
elems = bytes/4
data_arr = struct.unpack('f'*elems, f.read(4*elems))
print (np.amin(data_arr))
print (np.amax(data_arr))
if __name__ == "__main__":
dir_prefix = "model_params/alexnet2_cifar10/"
print dir_prefix
read_value_range(dir_prefix + "norm_cifar_input.bin")
read_value_range(dir_prefix + "conv1.bin")
read_value_range(dir_prefix + "conv1_bias.bin")
read_value_range(dir_prefix + "conv2.bin")
read_value_range(dir_prefix + "conv2_bias.bin")
read_value_range(dir_prefix + "conv3.bin")
read_value_range(dir_prefix + "conv3_bias.bin")
read_value_range(dir_prefix + "conv4.bin")
read_value_range(dir_prefix + "conv4_bias.bin")
read_value_range(dir_prefix + "conv5.bin")
read_value_range(dir_prefix + "conv5_bias.bin")
read_value_range(dir_prefix + "conv6.bin")
read_value_range(dir_prefix + "conv6_bias.bin")
read_value_range(dir_prefix + "fc1.bin")
read_value_range(dir_prefix + "fc1_bias.bin")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment