Module: tfm.vision.sampling_ops
Stay organized with collections
Save and categorize content based on your preferences.
Class to subsample minibatches by balancing positives and negatives.
Subsamples minibatches based on a pre-specified positive fraction in range
[0,1]. The class presumes there are many more negatives than positive examples:
if the desired batch_size cannot be achieved with the pre-specified positive
fraction, it fills the rest with negative examples. If this is not sufficient
for obtaining the desired batch_size, it returns fewer examples.
The main function to call is Subsample(self, indicator, labels). For convenience
one can also call SubsampleWeights(self, weights, labels) which is defined in
the minibatch_sampler base class.
When is_static is True, it implements a method that guarantees static shapes.
It also ensures the length of output of the subsample is always batch_size, even
when number of examples set to True in indicator is less than batch_size.
This is originally implemented in TensorFlow Object Detection API.
Classes
class BalancedPositiveNegativeSampler
: Subsamples minibatches to a desired balance of positives and negatives.
Functions
combined_static_and_dynamic_shape(...)
: Returns a list containing static and dynamic values for the dimensions.
indices_to_dense_vector(...)
: Creates dense vector with indices set to specific value and rest to zeros.
matmul_gather_on_zeroth_axis(...)
: Matrix multiplication based implementation of tf.gather on zeroth axis.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-02-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-02-02 UTC."],[],[],null,["# Module: tfm.vision.sampling_ops\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/models/blob/v2.15.0/official/vision/ops/sampling_ops.py) |\n\nClass to subsample minibatches by balancing positives and negatives.\n\nSubsamples minibatches based on a pre-specified positive fraction in range\n\\[0,1\\]. The class presumes there are many more negatives than positive examples:\nif the desired batch_size cannot be achieved with the pre-specified positive\nfraction, it fills the rest with negative examples. If this is not sufficient\nfor obtaining the desired batch_size, it returns fewer examples.\n\nThe main function to call is Subsample(self, indicator, labels). For convenience\none can also call SubsampleWeights(self, weights, labels) which is defined in\nthe minibatch_sampler base class.\n\nWhen is_static is True, it implements a method that guarantees static shapes.\nIt also ensures the length of output of the subsample is always batch_size, even\nwhen number of examples set to True in indicator is less than batch_size.\n\nThis is originally implemented in TensorFlow Object Detection API.\n\nClasses\n-------\n\n[`class BalancedPositiveNegativeSampler`](../../tfm/vision/sampling_ops/BalancedPositiveNegativeSampler): Subsamples minibatches to a desired balance of positives and negatives.\n\nFunctions\n---------\n\n[`combined_static_and_dynamic_shape(...)`](../../tfm/vision/sampling_ops/combined_static_and_dynamic_shape): Returns a list containing static and dynamic values for the dimensions.\n\n[`indices_to_dense_vector(...)`](../../tfm/vision/sampling_ops/indices_to_dense_vector): Creates dense vector with indices set to specific value and rest to zeros.\n\n[`matmul_gather_on_zeroth_axis(...)`](../../tfm/vision/sampling_ops/matmul_gather_on_zeroth_axis): Matrix multiplication based implementation of tf.gather on zeroth axis."]]