Skip to main content
TensorFlow
Install Learn
  • Introduction
    New to TensorFlow?
  • Tutorials
    Learn how to use TensorFlow with end-to-end examples
  • Guide
    Learn framework concepts and components
  • Learn ML
    Educational resources to master your path with TensorFlow
API
  • TensorFlow (v2.16.1)
  • Versions…
  • TensorFlow.js
  • TensorFlow Lite
  • TFX
Ecosystem
  • LIBRARIES
  • TensorFlow.js
    Develop web ML applications in JavaScript
  • TensorFlow Lite
    Deploy ML on mobile, microcontrollers and other edge devices
  • TFX
    Build production ML pipelines
  • All libraries
    Create advanced models and extend TensorFlow
  • RESOURCES
  • Models & datasets
    Pre-trained models and datasets built by Google and the community
  • Tools
    Tools to support and accelerate TensorFlow workflows
  • Responsible AI
    Resources for every stage of the ML workflow
  • Recommendation systems
    Build recommendation systems with open source tools
Community
  • Groups
    User groups, interest groups and mailing lists
  • Contribute
    Guide for contributing to code and documentation
  • Blog
    Stay up to date with all things TensorFlow
  • Forum
    Discussion platform for the TensorFlow community
Why TensorFlow
  • About
  • Case studies
/
  • English
  • 中文 – 简体
GitHub Sign in
  • TensorFlow v2.16.1
Overview Python C++ Java More
TensorFlow
  • Install
  • Learn
    • More
  • API
    • More
    • Overview
    • Python
    • C++
    • Java
    • More
  • Ecosystem
    • More
  • Community
    • More
  • Why TensorFlow
    • More
  • GitHub
  • Overview
  • TensorFlow Models
  • tfm
    • Overview
  • tfm.core
    • Overview
    • actions
      • Overview
      • EMACheckpointing
      • PruningAction
      • RecoveryAction
      • RecoveryCondition
      • get_eval_actions
      • get_train_actions
    • base_task
      • Overview
      • DifferentialPrivacyConfig
      • RuntimeConfig
      • Task
    • base_trainer
      • Overview
      • ExperimentConfig
      • Trainer
      • TrainerConfig
      • get_runtime_options
    • config_definitions
      • Overview
      • DataConfig
      • TaskConfig
    • exp_factory
      • Overview
      • get_exp_config
      • register_config_factory
    • export_base
      • Overview
      • ExportModule
      • export
      • get_timestamped_export_dir
    • file_writers
      • Overview
      • write_small_dataset
    • input_reader
      • Overview
      • InputReader
      • match_files
    • registry
      • Overview
      • lookup
      • register
    • savedmodel_checkpoint_manager
      • Overview
      • SavedModelCheckpointManager
      • make_saved_modules_directory_name
    • task_factory
      • Overview
      • get_task
      • get_task_cls
      • register_task_cls
    • tf_example_builder
      • Overview
      • BytesValueType
      • TfExampleBuilder
    • tf_example_feature_key
      • Overview
      • TfExampleFeatureKeyBase
      • dataclass
    • train_lib
      • Overview
      • OrbitExperimentRunner
      • maybe_create_best_ckpt_exporter
      • run_experiment
    • train_utils
      • Overview
      • BestCheckpointExporter
      • ExperimentParser
      • ParseConfigOptions
      • cast_leaf_nested_dict
      • convert_variables_to_constants_v2_as_graph
      • create_optimizer
      • create_trainer
      • get_leaf_nested_dict
      • parse_configuration
      • read_global_step_from_checkpoint
      • remove_ckpts
      • save_gin_config
      • serialize_config
      • try_count_flops
      • try_count_params
      • write_json_summary
      • write_model_params
      • write_summary
  • tfm.hyperparams
    • Overview
    • Config
    • OneOfConfig
    • ParamsDict
    • bind
    • nested_csv_str_to_json_str
    • override_params_dict
    • read_yaml_to_params_dict
    • save_params_dict_to_yaml
    • base_config
      • Overview
    • oneof
      • Overview
    • params_dict
      • Overview
  • tfm.nlp
    • Overview
    • encoders
      • Overview
      • AlbertEncoderConfig
      • BertEncoderConfig
      • BigBirdEncoderConfig
      • EncoderConfig
      • FNetEncoderConfig
      • FunnelEncoderConfig
      • KernelEncoderConfig
      • MobileBertEncoderConfig
      • QueryBertConfig
      • ReuseEncoderConfig
      • SparseMixerEncoderConfig
      • XLNetEncoderConfig
      • build_encoder
    • layers
      • Overview
      • BertPackInputs
      • BertTokenizer
      • BigBirdAttention
      • BigBirdMasks
      • BlockDiagFeedforward
      • CachedAttention
      • ClassificationHead
      • ExpertsChooseMaskedRouter
      • FactorizedEmbedding
      • FastWordpieceBertTokenizer
      • FeedForwardExperts
      • FourierTransformLayer
      • GatedFeedforward
      • GaussianProcessClassificationHead
      • HartleyTransformLayer
      • KernelAttention
      • KernelMask
      • LinearTransformLayer
      • MaskedLM
      • MaskedSoftmax
      • MatMulWithMargin
      • MixingMechanism
      • MobileBertEmbedding
      • MobileBertMaskedLM
      • MobileBertTransformer
      • MoeLayer
      • MoeLayerWithBackbone
      • MultiChannelAttention
      • MultiClsHeads
      • MultiHeadRelativeAttention
      • OnDeviceEmbedding
      • PackBertEmbeddings
      • PerDimScaleAttention
      • PerQueryDenseHead
      • PositionEmbedding
      • RandomFeatureGaussianProcess
      • ReZeroTransformer
      • RelativePositionBias
      • RelativePositionEmbedding
      • ReuseMultiHeadAttention
      • ReuseTransformer
      • SelectTopK
      • SelfAttentionMask
      • SentencepieceTokenizer
      • SpectralNormalization
      • SpectralNormalizationConv2D
      • StridedTransformerEncoderBlock
      • StridedTransformerScaffold
      • TNTransformerExpandCondense
      • TalkingHeadsAttention
      • TokenImportanceWithMovingAvg
      • Transformer
      • TransformerDecoderBlock
      • TransformerEncoderBlock
      • TransformerScaffold
      • TransformerXL
      • TransformerXLBlock
      • TwoStreamRelativeAttention
      • VotingAttention
      • extract_gp_layer_kwargs
      • extract_spec_norm_kwargs
      • get_mask
      • util
        • Overview
        • TfFunctionIfEagerDecorator
        • filter_kwargs
        • tf_function_if_eager
    • losses
      • Overview
      • weighted_sparse_categorical_crossentropy_loss
    • models
      • Overview
      • BertClassifier
      • BertPretrainer
      • BertPretrainerV2
      • BertSpanLabeler
      • BertTokenClassifier
      • DualEncoder
      • ElectraPretrainer
      • Seq2SeqTransformer
      • T5Transformer
      • T5TransformerParams
      • TransformerDecoder
      • TransformerEncoder
      • XLNetClassifier
      • XLNetPretrainer
      • XLNetSpanLabeler
      • attention_initializer
    • networks
      • Overview
      • AlbertEncoder
      • BertEncoder
      • BertEncoderV2
      • Classification
      • EncoderScaffold
      • FNet
      • FunnelTransformerEncoder
      • MobileBERTEncoder
      • PackedSequenceEmbedding
      • SpanLabeling
      • SparseMixer
      • XLNetBase
      • XLNetSpanLabeling
    • ops
      • Overview
      • SamplingModule
      • SequenceBeamSearch
      • get_next_sentence_labels
      • get_sentence_order_labels
      • sequence_beam_search
    • serving_modules
      • Overview
      • MaskedLM
      • MaskedLM.Params
      • QuestionAnswering
      • QuestionAnswering.Params
      • SentencePrediction
      • SentencePrediction.Params
      • Tagging
      • Tagging.Params
      • Translation
      • Translation.Params
      • features_to_int32
    • tasks
      • Overview
      • ElectraPretrainConfig
      • ElectraPretrainTask
      • MaskedLMConfig
      • MaskedLMTask
      • QuestionAnsweringConfig
      • QuestionAnsweringTask
      • SentencePredictionConfig
      • SentencePredictionTask
      • TaggingConfig
      • TaggingTask
      • TranslationConfig
      • TranslationTask
  • tfm.optimization
    • Overview
    • AdafactorConfig
    • AdagradConfig
    • AdamConfig
    • AdamExperimentalConfig
    • AdamWeightDecayConfig
    • AdamWeightDecayExperimentalConfig
    • BaseOptimizerConfig
    • ConstantLrConfig
    • CosineDecayWithOffset
    • CosineDecayWithOffset.base_lr_class
    • CosineLrConfig
    • DirectPowerDecay
    • DirectPowerLrConfig
    • EMAConfig
    • ExponentialDecayWithOffset
    • ExponentialDecayWithOffset.base_lr_class
    • ExponentialLrConfig
    • ExponentialMovingAverage
    • LAMBConfig
    • LARSConfig
    • LinearWarmup
    • LinearWarmupConfig
    • LrConfig
    • OptimizationConfig
    • OptimizerConfig
    • OptimizerFactory
    • PiecewiseConstantDecayWithOffset
    • PiecewiseConstantDecayWithOffset.base_lr_class
    • PolynomialDecayWithOffset
    • PolynomialDecayWithOffset.base_lr_class
    • PolynomialLrConfig
    • PolynomialWarmUp
    • PolynomialWarmupConfig
    • PowerAndLinearDecay
    • PowerAndLinearDecayLrConfig
    • PowerDecayWithOffset
    • PowerDecayWithOffsetLrConfig
    • RMSPropConfig
    • SGDConfig
    • SGDExperimentalConfig
    • SLIDEConfig
    • StepCosineDecayWithOffset
    • StepCosineLrConfig
    • StepwiseLrConfig
    • WarmupConfig
    • register_optimizer_cls
    • adafactor_optimizer
      • Overview
    • configs
      • Overview
    • ema_optimizer
      • Overview
      • maybe_merge_call
    • lamb
      • Overview
      • FloatTensorLike
      • LAMB
    • lars
      • Overview
      • LARS
    • legacy_adamw
      • Overview
      • AdamWeightDecay
    • lr_cfg
      • Overview
    • lr_schedule
      • Overview
    • math
      • Overview
      • acos
      • acosh
      • asin
      • asinh
      • atan
      • atan2
      • atanh
      • ceil
      • comb
      • copysign
      • cos
      • cosh
      • degrees
      • dist
      • erf
      • erfc
      • exp
      • expm1
      • fabs
      • factorial
      • floor
      • fmod
      • frexp
      • fsum
      • gamma
      • gcd
      • hypot
      • isclose
      • isfinite
      • isinf
      • isnan
      • isqrt
      • lcm
      • ldexp
      • lgamma
      • log
      • log10
      • log1p
      • log2
      • modf
      • nextafter
      • perm
      • pow
      • prod
      • radians
      • remainder
      • sin
      • sinh
      • sqrt
      • tan
      • tanh
      • trunc
      • ulp
    • opt_cfg
      • Overview
    • optimizer_factory
      • Overview
    • slide_optimizer
      • Overview
  • tfm.utils
    • Overview
    • assert_rank
    • clone_initializer
    • cross_replica_concat
    • deserialize_keras_object
    • get_activation
    • get_replica_id
    • get_shape_list
    • is_special_none_tensor
    • pack_inputs
    • safe_mean
    • serialize_activation
    • serialize_constraint
    • serialize_initializer
    • serialize_keras_object
    • serialize_layer
    • serialize_regularizer
    • unpack_inputs
    • activations
      • Overview
      • gelu
      • hard_sigmoid
      • hard_swish
      • identity
      • mish
      • relu6
      • simple_swish
  • tfm.vision
    • Overview
    • ImageClassificationTask
    • MaskRCNNTask
    • RetinaNetTask
    • SemanticSegmentationTask
    • VideoClassificationTask
    • anchor
      • Overview
      • Anchor
      • AnchorLabeler
      • RpnAnchorLabeler
      • build_anchor_generator
      • unpack_targets
    • anchor_generator
      • Overview
      • AnchorGenerator
      • maybe_map_structure_for_anchor
    • augment
      • Overview
      • AutoAugment
      • ImageAugment
      • MixupAndCutmix
      • RandAugment
      • RandomErasing
      • autocontrast
      • bbox_wrapper
      • blend
      • brightness
      • color
      • contrast
      • cutout
      • cutout_video
      • equalize
      • from_4d
      • gaussian_filter2d
      • gaussian_noise
      • grayscale
      • invert
      • level_to_arg
      • posterize
      • rotate
      • rotate_with_bboxes
      • select_and_apply_random_policy
      • sharpness
      • shear_with_bboxes
      • shear_x
      • shear_y
      • solarize
      • solarize_add
      • to_4d
      • transform
      • translate
      • translate_bbox
      • translate_x
      • translate_y
      • translate_y_only_bboxes
      • unwrap
      • wrap
      • wrapped_rotate
    • backbones
      • Overview
      • DilatedResNet
      • EfficientNet
      • MobileDet
      • MobileNet
      • ResNet
      • ResNet3D
      • RevNet
      • SpineNet
      • SpineNetMobile
      • VisionTransformer
    • box_matcher
      • Overview
      • BoxMatcher
    • box_ops
      • Overview
      • bbox2mask
      • bbox_generalized_overlap
      • bbox_intersection_over_area
      • bbox_overlap
      • box_matching
      • clip_boxes
      • compute_outer_boxes
      • cycxhw_to_yxyx
      • decode_boxes
      • denormalize_boxes
      • encode_boxes
      • filter_boxes
      • filter_boxes_by_scores
      • gather_instances
      • get_non_empty_box_indices
      • horizontal_flip_boxes
      • jitter_boxes
      • normalize_boxes
      • top_k_boxes
      • vertical_flip_boxes
      • yxyx_to_cycxhw
      • yxyx_to_xywh
    • classification_model
      • Overview
      • ClassificationModel
    • configs
      • Overview
      • backbones
        • Overview
        • Backbone
        • DilatedResNet
        • EfficientNet
        • MobileDet
        • MobileNet
        • ResNet
        • RevNet
        • SpineNet
        • SpineNetMobile
        • Transformer
        • VisionTransformer