LogoLogo
  • Tensorleap
  • Examples
    • Semantic Segmentation
    • Image Analysis
    • Sentiment Analysis
    • MNIST Project Walkthrough
    • IMDB Project Walkthrough
  • Quickstart using CLI
  • Guides
    • Full Guides
      • MNIST Guide
        • Dataset Integration
        • Model Integration
        • Model Perception Analysis
        • Advanced Metrics
      • IMDB Guide
        • Dataset Integration
        • Model Integration
        • Model Perception Analysis
        • Advanced Metrics
    • Integration Script
      • Preprocess Function
      • Input Encoder
      • Ground Truth Encoder
      • Metadata Function
      • Visualizer Function
      • Prediction
      • Custom Metrics
      • Custom Loss Function
      • Custom Layers
      • Unlabeled Data
      • Examples
        • CelebA Object Detection (YoloV7)
        • Wikipedia Toxicity (using Tensorflow Datasets)
        • Confusion Matrix
        • CelebA Classification (using GCS)
  • Platform
    • Resources Management
    • Project
    • Dataset
    • Secret Manager
    • Network
      • Dataset Node
      • Layers
      • Loss and Optimizer
      • Visualizers
      • Import Model
      • Metrics
    • Evaluate / Train Model
    • Metrics Dashboard
    • Versions
    • Issues
    • Tests
    • Analysis
      • helpers
        • detection
          • YOLO
    • Team management
    • Insights
  • API
    • code_loader
      • leap_binder
        • add_custom_metric
        • set_preprocess
        • set_unlabeled_data_preprocess
        • set_input
        • set_ground_truth
        • set_metadata
        • add_prediction
        • add_custom_loss
        • set_visualizer
      • enums
        • DatasetMetadataType
        • LeapDataType
      • datasetclasses
        • PreprocessResponse
      • visualizer_classes
        • LeapImage
        • LeapImageWithBBox
        • LeapGraph
        • LeapText
        • LeapHorizontalBar
        • LeapImageMask
        • LeapTextMask
  • Tips & Tricks
    • Import External Code
  • Legal
    • Terms of Use
    • Privacy Policy
Powered by GitBook
On this page

Was this helpful?

  1. Guides
  2. Integration Script

Custom Metrics

PreviousPredictionNextCustom Loss Function

Last updated 2 years ago

Was this helpful?

You can write your own custom metrics to be calculated and stored for later use within the .

Tensorleap stores metrics and metadata for every sample. This allows the user to investigate certain populations within the dataset. This also means that the custom metric is calculated per prediction on a single sample.

Example of usage:

def custom_metric_mean_distance(y_true, y_pred):
    rank = len(y_true.shape)
    axis = range(1, rank)
    diff = y_true - y_pred
    return tf.reduce_mean(diff, axis=axis)

leap_binder.add_custom_metric(custom_metric_mean_distance, "mean distance")

Once this metric is parsed within the dataset script, it should be added to the model as a block.

This is done by:

  1. right clicking on the Network view,

  2. choosing Metric

  3. Selecting the required Metric from the Node Details menu

  4. Connecting the metric to the relevant blocks.

Metrics Dashboard
Adding a custom metric to the model