Skip to content

Latest commit

 

History

History
121 lines (70 loc) · 3.16 KB

FrequencyRestrictPolicy.md

File metadata and controls

121 lines (70 loc) · 3.16 KB

tfra.dynamic_embedding.FrequencyRestrictPolicy

View source on GitHub




Class FrequencyRestrictPolicy

A derived policy to eliminate features in variable follow the

Inherits From: RestrictPolicy

lowest-occurrence-out-first rule.

__init__

View source

__init__(var)

A frequency status sparse variable is created. The frequency status has same key_dtype as the target variable and value_dtype in int32, which indicates the occurrence times of the feature.

Args:

Properties

status

Get status variable which save information about properties of features.

Methods

apply_restriction

View source

apply_restriction(
    num_reserved,
    **kwargs
)

Define the rule to restrict the size of the target variable by eliminating k features with least occurrence, and number of num_reserved features will be left.

Args:

  • num_reserved: int. Number of remained keys after restriction.
  • **kwargs: (Optional) reserved keyword arguments. trigger: int. The triggered threshold to execute restriction. Default equals to num_reserved.

Returns:

An operation to do restriction.

apply_update

View source

apply_update(ids)

Define the rule to update the frequency status. If any feature shows up, then its frequency value will be increased by 1.

Args:

  • ids: A Tensor. Keys appear in training. These keys in status variable will be updated if needed.

Returns:

An operation to update timestamp status.