View source on GitHub |
A derived policy to eliminate features in variable follow the
Inherits From: RestrictPolicy
lowest-occurrence-out-first
rule.
__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.
var
: Adynamic_embedding.Variable
object to be restricted.
Get status variable which save information about properties of features.
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.
num_reserved
: int. Number of remained keys after restriction.**kwargs
: (Optional) reserved keyword arguments. trigger: int. The triggered threshold to execute restriction. Default equals tonum_reserved
.
An operation to do restriction.
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.
ids
: A Tensor. Keys appear in training. These keys in status variable will be updated if needed.
An operation to update timestamp status.