@tensorleap_integration_test
code_loader.inner_leap_binder.leapbinder_decorators.tensorleap_integration_test
The tensorleap_integration_test decorates Tensorleap's integration test, and is used to instruct the platform on what code interfaces should be used when analyzing your model and to locally test the validity of a Tensorleap integration script.
@tensorleap_integration_test()
def integration_test(idx: int, subset: PreprocessResponse) -> None:
pass
Examples
Basic Usage
import os
from code_loader.plot_functions.visualize import visualize
from leap_binder import (input_encoder, preprocess_func_leap, gt_encoder,
combined_bar, metrics, image_visualizer, categorical_crossentropy_loss,
metadata_sample_index, metadata_one_hot_digit, metadata_euclidean_distance_from_class_centroid)
import tensorflow as tf
from code_loader.inner_leap_binder.leapbinder_decorators import integration_test
...
@tensorleap_integration_test()
def integration_test(idx, subset):
# Get input and GT
image = input_encoder(idx, subset)
gt = gt_encoder(idx, subset)
# Load Model and infer
cnn = load_model()
y_pred = cnn([image])
# Visualize the inputs and outputs of the model
horizontal_bar_vis = combined_bar(y_pred, gt)
img_vis = image_visualizer(image)
visualize(img_vis)
visualize(horizontal_bar_vis)
# Compute metrics and loss
metric_res = metrics(y_pred)
loss_res = categorical_crossentropy_loss(gt, y_pred)
print(metric_res)
print(loss_res)
# Compute metadata
m1 = metadata_sample_index(idx, subset)
m2 = metadata_one_hot_digit(idx, subset)
m3 = metadata_euclidean_distance_from_class_centroid(idx, subset)
print(m1)
print(m2)
print(m3)
# here the user can return whatever he wants
if __name__ == '__main__':
num_samples_to_test = 3
train, val = preprocess_func_leap()
for i in range(num_samples_to_test):
integration_test(i, train)
integration_test(i, val)
Last updated
Was this helpful?