SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2202.11132 · AAAI · 2022

Bag Graph: Multiple Instance Learning Using Bayesian Graph Neural Networks

Soumyasundar Pal, Mark Coates, Florence Regol, Antonios Valkanas

arXiv · PDF · Open in the Atlas

Code that ran

2 of 2 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 0 failures of our instrument; 0 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2202.11132.json · badge: /api/ran/2202.11132.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
networkslab/baggraph marked official in Papers with Code
Papers with Code archive
2 ran · 0 no recorded run
FunctionStatusWhere it lives
DSNetGCN Ran
ran on a synthesized input
networkslab/baggraph/mil_benchmark/models_all.py
code served (permissive licence) · get_code("b6864c51c845bf38")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import torch.nn.functional as F
import math
from torch.nn.parameter import Parameter
from torch.nn.modules.module import Module

class GraphConvolution(Module):
    """
    Simple GCN layer, similar to https://arxiv.org/abs/1609.02907
    """

    def __init__(self, in_features, out_features, bias=True):
        super(GraphConvolution, self).__init__()
        self.in_features = in_features
        self.out_features = out_features
        self.weight = Parameter(torch.FloatTensor(in_features, out_features))
        if bias:
            self.bias = Parameter(torch.FloatTensor(out_features))
        else:
            self.register_parameter('bias', None)
        self.reset_parameters()

    def reset_parameters(self):
        stdv = 1.0 / math.sqrt(self.in_features)
        self.weight.data.uniform_(-stdv, stdv)
        if self.bias is not None:
            self.bias.data.uniform_(-stdv, stdv)

    def forward(self, input, adj):
        support = torch.mm(input, self.weight)
        output = torch.mm(adj, support)
        if self.bias is not None:
            return output + self.bias
        else:
            return output

    def __repr__(self):
        return self.__class__.__name__ + ' (' + str(self.in_features) + ' -> ' + str(self.out_features) + ')'

class DSNetGCN(nn.Module):

    def __init__(self, in_features=200, pooling_method='max'):
        super(DSNetGCN, self).__init__()
        self.in_features = in_features
        self.pooling_method = pooling_method
        self.ll1 = nn.Linear(in_features, 256)
        self.d1 = nn.Dropout(p=0.5)
        self.ll2 = nn.Linear(256, 128)
        self.d2 = nn.Dropout(p=0.5)
        self.ll3 = nn.Linear(128, 64)
        self.d3 = nn.Dropout(p=0.5)
        self.gc1 = GraphConvolution(256, 1)
        self.gc2 = GraphConvolution(128, 1)
        self.gc3 = GraphConvolution(64, 1)
        self.reset_parameters()

    def reset_parameters(self):
        for module in self.children():
            reset_op = getattr(module, 'reset_parameters', None)
            if callable(reset_op):
                reset_op()

    def forward(self, input, adj):
        x = input
        x1 = [F.relu(self.ll1(x_)) for x_ in x]
        x2 = [F.relu(self.ll2(x_)) for x_ in x1]
        x3 = [F.relu(self.ll3(x_)) for x_ in x2]
        if self.pooling_method == 'max':
            x1 = [torch.unsqueeze(torch.max(self.d1(x_), axis=0)[0], 0) for x_ in x1]
            x2 = [torch.unsqueeze(torch.max(self.d2(x_), axis=0)[0], 0) for x_ in x2]
            x3 = [torch.unsqueeze(torch.max(self.d3(x_), axis=0)[0], 0) for x_ in x3]
        elif self.pooling_method == 'mean':
            x1 = [torch.unsqueeze(self.d1(x_).mean(dim=0), 0) for x_ in x1]
            x2 = [torch.unsqueeze(self.d2(x_).mean(dim=0), 0) for x_ in x2]
            x3 = [torch.unsqueeze(self.d3(x_).mean(dim=0), 0) for x_ in x3]
        elif self.pooling_method == 'sum':
            x1 = [torch.unsqueeze(self.d1(x_).sum(dim=0), 0) for x_ in x1]
            x2 = [torch.unsqueeze(self.d2(x_).sum(dim=0), 0) for x_ in x2]
            x3 = [torch.unsqueeze(self.d3(x_).sum(dim=0), 0) for x_ in x3]
        else:
            print('Invalid Pooling method!!!!!!')
            exit(0)
        x1 = torch.cat(x1, axis=0)
        x2 = torch.cat(x2, axis=0)
        x3 = torch.cat(x3, axis=0)
        embedding = torch.cat((x1, x2, x3), -1).cpu().detach().numpy()
        x1 = torch.sigmoid(self.gc1(x1, adj))
        x2 = torch.sigmoid(self.gc2(x2, adj))
        x3 = torch.sigmoid(self.gc3(x3, adj))
        x4 = (x1 + x2 + x3) / 3.0
        return (x1, x2, x3, x4, embedding)


INIT_ARGS = {
    'in_features': 4,
    'pooling_method': 'max'
}

ARGS = {
    'input': [torch.randn(2, 4), torch.randn(3, 4)],
    'adj': torch.randn(2, 2)
}

if __name__ == '__main__':
    model = DSNetGCN(**INIT_ARGS)
    output = model(**ARGS)
    print("Output shapes:")
    print(f"x1 shape: {output[0].shape}")
    print(f"x2 shape: {output[1].shape}")
    print(f"x3 shape: {output[2].shape}")
    print(f"x4 shape: {output[3].shape}")
    print(f"embedding shape: {output[4].shape}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
GraphConvolution Ran
ran on a synthesized input
networkslab/baggraph/mil_benchmark/models_all.py
code served (permissive licence) · get_code("032e0ff1009bd8fa")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import math
from torch.nn.parameter import Parameter
from torch.nn.modules.module import Module

class GraphConvolution(Module):
    """
    Simple GCN layer, similar to https://arxiv.org/abs/1609.02907
    """

    def __init__(self, in_features, out_features, bias=True):
        super(GraphConvolution, self).__init__()
        self.in_features = in_features
        self.out_features = out_features
        self.weight = Parameter(torch.FloatTensor(in_features, out_features))
        if bias:
            self.bias = Parameter(torch.FloatTensor(out_features))
        else:
            self.register_parameter('bias', None)
        self.reset_parameters()

    def reset_parameters(self):
        stdv = 1.0 / math.sqrt(self.in_features)
        self.weight.data.uniform_(-stdv, stdv)
        if self.bias is not None:
            self.bias.data.uniform_(-stdv, stdv)

    def forward(self, input, adj):
        support = torch.mm(input, self.weight)
        output = torch.mm(adj, support)
        if self.bias is not None:
            return output + self.bias
        else:
            return output

    def __repr__(self):
        return self.__class__.__name__ + ' (' + str(self.in_features) + ' -> ' + str(self.out_features) + ')'


INIT_ARGS = {
    'in_features': 4,
    'out_features': 3,
    'bias': True,
}

ARGS = {
    'input': torch.randn(2, 4),
    'adj': torch.randn(2, 2),
}

if __name__ == '__main__':
    gcn = GraphConvolution(**INIT_ARGS)
    output = gcn(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output:\n{output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)

Also present in other papers' code

Of 2 samples lifted from this paper's linked repositories, 2 carry a function identity and 0 do not. Of the 2 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 2 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Multiple Instance Learning (MIL) is a weakly supervised learning problem where the aim is to assign labels to sets or bags of instances, as opposed to traditional supervised learning where each instance is assumed to be independent and identically distributed (i.i.d.) and is to be labeled individually. Recent work has shown promising results for neural network models in the MIL setting. Instead of focusing on each instance, these models are trained in an end-to-end fashion to learn effective bag-level representations by suitably combining permutation invariant pooling techniques with neural architectures. In this paper, we consider modelling the interactions between bags using a graph and employ Graph Neural Networks (GNNs) to facilitate end-to-end learning. Since a meaningful graph representing dependencies between bags is rarely available, we propose to use a Bayesian GNN framework that can generate a likely graph structure for scenarios where there is uncertainty in the graph or when no graph is available. Empirical results demonstrate the efficacy of the proposed technique for several MIL benchmark tasks and a distribution regression task.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2202.11132")
get_code_for_paper("2202.11132")
have("2202.11132")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2202.11132.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2202.11132.svg)](https://syntology.ai/paper/2202.11132)

Connect an agent — have() is free.