```
import tensorflow as tf
def create_conv_layer(input_data, num_input_channels, num_filters, filter_shape, name):
conv_filt_shape = [filter_shape[0], filter_shape[1], num_input_channels, num_filters]
weights = tf.compat.v1.Variable(tf.compat.v1.truncated_normal(conv_filt_shape, stddev=0.03), name=name+'_W')
bias = tf.compat.v1.Variable(tf.compat.v1.truncated_normal([num_filters]), name=name+'_b')
out_layer = tf.compat.v1.nn.conv2d(input_data, weights, [1, 1, 1, 1], padding='SAME')
out_layer += bias
return out_layer
with tf.compat.v1.Session() as sess:
input_shape = (1, 224, 224, 3)
# Model consisting of 1 convolution layer
x_in = tf.compat.v1.placeholder(tf.compat.v1.float32, input_shape)
x_out = create_conv_layer(x_in, 3, 64, [3, 3], name='layer1')
init = tf.compat.v1.global_variables_initializer()
sess.run(init)
converter = tf.compat.v1.lite.TFLiteConverter.from_session(sess, [x_in], [x_out])
converter.inference_type = tf.compat.v1.lite.constants.QUANTIZED_UINT8
input_arrays = converter.get_input_arrays()
# Define the correct input stats, more information about it:
# https://stackoverflow.com/questions/54830869/understanding-tf-contrib-lite-tfliteconverter-quantization-parameters
converter.quantized_input_stats = {input_arrays[0]: (127.5, 127.5)}
# Using "dummy" quantization ranges
converter.default_ranges_stats = (-10.0, 10.0)
tflite_model = converter.convert()
open('quantized_model.tflite', 'wb').write(tflite_model)
```