fairlib.src.networks.DyBT

fairlib.src.networks.DyBT.gdl

class fairlib.src.networks.DyBT.gdl.Group_Difference_Loss(args)
forward(predictions, tags, p_tags, regression_tags=None)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

fairlib.src.networks.DyBT.fairbatch_sampler

class fairlib.src.networks.DyBT.fairbatch_sampler.FairBatch(model, args, replacement=False)

FairBatch (Sampler in DataLoader).

This class is for implementing the lambda adjustment and batch selection of FairBatch.

model

A model containing the intermediate states of the training.

x_, y_, g_data

Tensor-based train data.

alpha

A positive number for step size that used in the lambda adjustment.

fairness_type

A string indicating the target fairness type stratified_y : equalized odds (eqodds) in binary and equal opportunity (eqopp) in multi-class classification stratified_g : demographic parity

replacement

A boolean indicating whether a batch consists of data with or without replacement.

N

An integer counting the size of data.

batch_size

An integer for the size of a batch.

batch_num

An integer for total number of batches in an epoch.

y_, g_item

Lists that contains the unique values of the y_data and g_data, respectively.

yg_tuple

Lists for pairs of y_item and g_item.

y_, g_, yg_mask

Dictionaries utilizing as array masks.

y_, g_, yg_index

Dictionaries containing the index of each class.

y_, g_, yg_len

Dictionaries containing the length information.

S

A dictionary containing the default size of each class in a batch.

lb_dict

A dictionary of real numbers indicating the lambda values in FairBatch.

adjust_lambda()

Adjusts the lambda values for FairBatch algorithm.

The detailed algorithms are decribed in the paper.

select_batch_replacement(batch_size, full_index, batch_num, replacement=False)

Selects a certain number of batches based on the given batch size.

Parameters
  • batch_size – An integer for the data size in a batch.

  • full_index – An array containing the candidate data indices.

  • batch_num – An integer indicating the number of batches.

  • replacement – A boolean indicating whether a batch consists of data with or without replacement.

Returns

Indices that indicate the data.

fairlib.src.networks.DyBT.utils

class fairlib.src.networks.DyBT.utils.BaseDyBT(model, args, replacement=False)

Base Sample Class (Sampler in DataLoader). .. attribute:: model

A model containing the intermediate states of the training.

x_, y_, g_data

Tensor-based train data.

alpha

A positive number for step size that used in the lambda adjustment.

fairness_type

A string indicating the target fairness type stratified_y : equalized odds (eqodds) in binary and equal opportunity (eqopp) in multi-class classification stratified_g : demographic parity

replacement

A boolean indicating whether a batch consists of data with or without replacement.

N

An integer counting the size of data.

batch_size

An integer for the size of a batch.

batch_num

An integer for total number of batches in an epoch.

y_, g_item

Lists that contains the unique values of the y_data and g_data, respectively.

yg_tuple

Lists for pairs of y_item and g_item.

y_, g_, yg_mask

Dictionaries utilizing as array masks.

y_, g_, yg_index

Dictionaries containing the index of each class.

y_, g_, yg_len

Dictionaries containing the length information.

S

A dictionary containing the default size of each class in a batch.

lb_dict

A dictionary of real numbers indicating the lambda values in FairBatch.

adjust_lambda()

Adjusts the lambda values for each group

select_batch_replacement(batch_size, full_index, batch_num, replacement=False)

Selects a certain number of batches based on the given batch size.

Parameters
  • batch_size – An integer for the data size in a batch.

  • full_index – An array containing the candidate data indices.

  • batch_num – An integer indicating the number of batches.

  • replacement – A boolean indicating whether a batch consists of data with or without replacement.

Returns

Indices that indicate the data.

fairlib.src.networks.DyBT.generalized_fairbatch

class fairlib.src.networks.DyBT.generalized_fairbatch.Generalized_FairBatch(model, args, replacement=False)
adjust_lambda()

Adjusts the lambda values for each group