Skip to content

dual_lphm_parameterized_bilinear_interdependence

Bases: parameterized_bilinear_interdependence

Source code in tinybig/interdependence/parameterized_bilinear_interdependence.py
class dual_lphm_parameterized_bilinear_interdependence(parameterized_bilinear_interdependence):
    def __init__(self, r: int, p: int, q: int = None, name: str = 'dual_lphm_parameterized_bilinear_interdependence', *args, **kwargs):
        super().__init__(name=name, *args, **kwargs)

        self.r = r
        self.p = p
        self.q = q if q is not None else p

        if self.interdependence_type in ['row', 'left', 'instance', 'instance_interdependence']:
            d, d_prime = self.m, self.calculate_m_prime()
        elif self.interdependence_type in ['column', 'right', 'attribute', 'attribute_interdependence']:
            d, d_prime = self.b, self.calculate_b_prime()
        else:
            raise ValueError(f'Interdependence type {self.interdependence_type} not supported')
        assert d % self.p == 0 and d_prime % self.q == 0

        self.parameter_fabrication = dual_lphm_reconciliation(p=self.p, q=self.q, r=self.r)