def measure_inference_accuracy(self):
    'Runs the inference model and measures accuracy on the validation set.'
    interpreter = tf.lite.Interpreter(model_content=self.inference_model)
    bottleneck_in = interpreter.get_input_details()[0]
    variable_ins = interpreter.get_input_details()[1:]
    [y_out] = interpreter.get_output_details()
    inference_accuracy = 0.0
    num_processed = 0
    for (bottleneck, truth) in self._generate_batches(self.val_bottlenecks, self.val_labels):
        batch_size = bottleneck.shape[0]
        interpreter.resize_tensor_input(bottleneck_in['index'], ((batch_size,) + BOTTLENECK_SHAPE))
        interpreter.allocate_tensors()
        interpreter.set_tensor(bottleneck_in['index'], bottleneck)
        for (variable_in, variable_value) in zip(variable_ins, self.variables):
            interpreter.set_tensor(variable_in['index'], variable_value)
        interpreter.invoke()
        preds = interpreter.get_tensor(y_out['index'])
        acc = ((np.argmax(preds, axis=1) == np.argmax(truth, axis=1)).sum() / batch_size)
        inference_accuracy += (acc * batch_size)
        num_processed += batch_size
    inference_accuracy /= num_processed
    return inference_accuracy
Runs the inference model and measures accuracy on the validation set.
def measure_inference_accuracy(self):
    
    interpreter = tf.lite.Interpreter(model_content=self.inference_model)
    bottleneck_in = interpreter.get_input_details()[0]
    variable_ins = interpreter.get_input_details()[1:]
    [y_out] = interpreter.get_output_details()
    inference_accuracy = 0.0
    num_processed = 0
    for (bottleneck, truth) in self._generate_batches(self.val_bottlenecks, self.val_labels):
        batch_size = bottleneck.shape[0]
        interpreter.resize_tensor_input(bottleneck_in['index'], ((batch_size,) + BOTTLENECK_SHAPE))
        interpreter.allocate_tensors()
        interpreter.set_tensor(bottleneck_in['index'], bottleneck)
        for (variable_in, variable_value) in zip(variable_ins, self.variables):
            interpreter.set_tensor(variable_in['index'], variable_value)
        interpreter.invoke()
        preds = interpreter.get_tensor(y_out['index'])
        acc = ((np.argmax(preds, axis=1) == np.argmax(truth, axis=1)).sum() / batch_size)
        inference_accuracy += (acc * batch_size)
        num_processed += batch_size
    inference_accuracy /= num_processed
    return inference_accuracy