Exemplo n.º 1
0
def get_activator_aids(dev_split, test_split, topological_ftrs=True):
    data_name = "Aids"
    ext_train = ExternalData(AidsAllExternalDataParams())
    ds_params = AidsDatasetAllParams()
    if not topological_ftrs:
        ds_params.FEATURES = []
    ds = BilinearDataset(ds_params, external_data=ext_train)
    activator_params = AidsBilinearActivatorParams()
    activator_params.TEST_SPLIT = test_split
    activator_params.DEV_SPLIT = dev_split
    module_params = AidsLayeredBilinearModuleParams(
        ftr_len=ds.len_features, embed_vocab_dim=ext_train.len_embed())
    return data_name, BilinearActivator(LayeredBilinearModule(module_params),
                                        activator_params, ds)
Exemplo n.º 2
0
def get_params_by_dataset(data):
    dict_classes = {
        "AIDS": [
            AidsDatasetAllParams, AidsLayeredBilinearModuleParams,
            AidsBilinearActivatorParams,
            ExternalData(AidsAllExternalDataParams()), False
        ],
        "PROTEIN": [
            ProteinDatasetAllParams, ProteinLayeredBilinearModuleParams,
            ProteinBilinearActivatorParams,
            ExternalData(ProteinAllExternalDataParams()), True
        ],
        "MUTAGEN": [
            MutagenDatasetAllParams, MutagenLayeredBilinearModuleParams,
            MutagenBilinearActivatorParams,
            ExternalData(MutagenAllExternalDataParams()), False
        ],
        "GREC": [
            GrecDatasetAllParams, GrecLayeredBilinearModuleParams,
            GrecBilinearActivatorParams,
            ExternalData(GrecAllExternalDataParams()), True
        ]
    }
    return dict_classes[data]
Exemplo n.º 3
0
            x0 = torch.cat([x0] + list_embed, dim=2)

        x1 = x0
        self._sync()
        for i in range(self._num_layers):
            x1 = self._linear_layers[i](A, x1)
        x2 = self._bilinear_layer(A, x0, x1)
        return x2


if __name__ == "__main__":
    from dataset.datset_sampler import ImbalancedDatasetSampler
    from params.aids_params import AidsAllExternalDataParams, AidsDatasetAllParams
    from dataset.dataset_external_data import ExternalData
    from dataset.dataset_model import BilinearDataset

    ext_train = ExternalData(AidsAllExternalDataParams())
    ds = BilinearDataset(AidsDatasetAllParams(), external_data=ext_train)
    dl = DataLoader(dataset=ds,
                    collate_fn=ds.collate_fn,
                    batch_size=64,
                    sampler=ImbalancedDatasetSampler(ds))
    m_params = LayeredBilinearModuleParams(
        ftr_len=ds.len_features, embed_vocab_dim=ext_train.len_embed())
    m_params.EMBED_DIMS = [20, 20]
    module = LayeredBilinearModule(m_params)
    # module = BilinearModule(BilinearModuleParams())
    for i, (_A, _D, _x0, _l) in enumerate(dl):
        _x2 = module(_A, _D, _x0)
        e = 0
Exemplo n.º 4
0
                           config + ftrs

            res_list.append(config_line)

        with open(os.path.join("grid_results", file_name.strip(".txt") + "_analyzed.csv"), "wt") as f:
            writer = csv.writer(f)
            writer.writerows(res_list)


if __name__ == "__main__":
    # n = int(sys.argv[1])
    n = 0

    if n == 0:
        GridSearch(AidsDatasetAllParams, AidsLayeredBilinearModuleParams, AidsBilinearActivatorParams,
                   ExternalData(AidsAllExternalDataParams()), multi_class=False).go("_Aids")
    #
    # elif n == 1:
    #     GridSearch(WebDatasetAllParams, WebLayeredBilinearModuleParams, WebBilinearActivatorParams,
    #                ExternalData(WebAllExternalDataParams()), multi_class=True,
    #                layers=[[[None, 50], [50, 25]], [[None, 200], [200, 100], [100, 50]]]).go("_Web")
    #
    # elif n == 2:
    #     GridSearch(MutagenDatasetAllParams, MutagenLayeredBilinearModuleParams, MutagenBilinearActivatorParams,
    #                ExternalData(MutagenAllExternalDataParams()), multi_class=False).go("_Mutagen")
    #
    # elif n == 3:
    #     GridSearch(ProteinDatasetAllParams, ProteinLayeredBilinearModuleParams, ProteinBilinearActivatorParams,
    #                ExternalData(ProteinAllExternalDataParams()), multi_class=True,
    #                layers=[[[None, 25], [50, 25]], [[None, 100], [100, 50], [50, 25]]]).go("_Protein")
    #
Exemplo n.º 5
0
        with open(
                os.path.join("grid_results",
                             file_name.strip(".txt") + "_analyzed.csv"),
                "wt") as f:
            writer = csv.writer(f)
            writer.writerows(res_list)


if __name__ == "__main__":
    n = 8  # int(sys.argv[1])

    if n == 0:
        GridSearch(AidsDatasetAllParams,
                   AidsLayeredBilinearModuleParams,
                   AidsBilinearActivatorParams,
                   ExternalData(AidsAllExternalDataParams()),
                   multi_class=False).go("_Aids")

    elif n == 1:
        GridSearch(WebDatasetAllParams,
                   WebLayeredBilinearModuleParams,
                   WebBilinearActivatorParams,
                   ExternalData(WebAllExternalDataParams()),
                   multi_class=True).go("_Web")

    elif n == 2:
        GridSearch(MutagenDatasetAllParams,
                   MutagenLayeredBilinearModuleParams,
                   MutagenBilinearActivatorParams,
                   ExternalData(MutagenAllExternalDataParams()),
                   multi_class=False).go("_Mutagen")