Skip to content

graph_interdependence_layer

Bases: layer

Source code in tinybig/layer/graph_based_layers.py
class graph_interdependence_layer(layer):
    def __init__(
        self,
        m: int, n: int,
        width: int = 1,
        name: str = 'graph_interdependence_layer',
        channel_num: int = 1,
        # graph structure parameters
        graph: graph_class = None,
        graph_file_path: str = None,
        nodes: list = None,
        links: list = None,
        directed: bool = False,
        # graph interdependence function parameters
        with_multihop: bool = False, h: int = 1, accumulative: bool = False,
        with_pagerank: bool = False, c: float = 0.15,
        require_data: bool = False,
        require_parameters: bool = False,
        # adj matrix processing parameters
        normalization: bool = True,
        normalization_mode: str = 'column',
        self_dependence: bool = True,
        # parameter reconciliation and remainder functions
        with_dual_lphm: bool = False,
        with_lorr: bool = False, r: int = 3,
        with_residual: bool = False,
        enable_bias: bool = False,
        # output processing parameters
        with_batch_norm: bool = False,
        with_relu: bool = True,
        with_softmax: bool = True,
        with_dropout: bool = True, p: float = 0.5,
        # other parameters
        parameters_init_method: str = 'xavier_normal',
        device: str = 'cpu', *args, **kwargs
    ):
        print('* graph_interdependence_layer, width:', width)
        heads = [
            graph_interdependence_head(
                m=m, n=n,
                channel_num=channel_num,
                # -------------------
                graph=graph,
                graph_file_path=graph_file_path,
                nodes=nodes,
                links=links,
                directed=directed,
                # -------------------
                with_multihop=with_multihop, h=h, accumulative=accumulative,
                with_pagerank=with_pagerank, c=c,
                require_data=require_data,
                require_parameters=require_parameters,
                # -------------------
                normalization=normalization,
                normalization_mode=normalization_mode,
                self_dependence=self_dependence,
                # -------------------
                with_dual_lphm=with_dual_lphm,
                with_lorr=with_lorr, r=r,
                with_residual=with_residual,
                enable_bias=enable_bias,
                # -------------------
                with_batch_norm=with_batch_norm,
                with_relu=with_relu,
                with_softmax=with_softmax,
                with_dropout=with_dropout, p=p,
                # -------------------
                parameters_init_method=parameters_init_method,
                device=device, *args, **kwargs
            )
        ] * width
        print('--------------------------')
        super().__init__(name=name, m=m, n=n, heads=heads, device=device, *args, **kwargs)