Dear AIMET Team,
I have studied all of your resources and can’t find the clear instructions on how to compress the model, built by Keras with TensorFlow backend. The docs posted here (Using AIMET with Keras Model — AI Model Efficiency Toolkit Documentation: ver tf-gpu_1.16.0) do not provide precise instructions. The description is really vague and it confuses me wether I have to retrain the model that I already have using aimet methods and then compress it or can I use the trained model I already have??
To be clear:
I have set up all the necessary environment on my Ubuntu 18.4.5 machine.
Python 3.6.9.
TF 1.15
AIMET 1.14
I have created and trained a TF model using Keras like so:
-------------------------------------------------------
# (i) define compiler func
def build_and_compile_model():
model = keras.Sequential([
layers.Dense(4, activation='relu'),
layers.Dense(8, activation='relu'),
layers.Dense(4, activation='relu'),
layers.Dense(3, activation='relu'),
layers.Dense(2, activation='relu'),
layers.Dense(1)
])
model.compile(loss='mean_absolute_error',
optimizer=tf.keras.optimizers.Adam(0.001))
return model
# (ii) compile
model = build_and_compile_model()
# (iii) train
history = model.fit(
train_features, train_labels,
validation_split=0.2,
verbose=2, epochs=500)
# (iv) evaluate model on validation data
val_predictions = model.predict(val_features).flatten()
print(f'MAE: {mae(val_labels, val_predictions)}')
# (v) save
model.save('tf_keras_model')
-------------------------------------------------------
Now that I have the trained model what are the exact steps that I have to undertake to:
- Compress this model
- Evaluate the compressed model on the same validation data that I used to evaluate the uncompressed model in the step (iv) above