SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2212.06515 · 2022

AdvMIL: Adversarial Multiple Instance Learning for the Survival Analysis on Whole-Slide Images

arXiv · PDF · Open in the Atlas

Code that ran

10 of 15 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 10 have no contract verdict; 0 failures of our instrument; 5 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/2212.06515.json · badge: /api/ran/2212.06515.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
liupei101/advmil canonical (classifier label)
classifier basis not recorded on the link
10 ran · 5 no recorded run
FunctionStatusWhere it lives
D_input_constructor Ran
ran on a synthesized input
liupei101/advmil/model_stats.py
code served (permissive licence) · get_code("3bdef6f68f5e39ae")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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

torch.manual_seed(0)

ARGS = {
    'args': ((2, 4, 8), 'tuple')
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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: none by the harness; any seed is in the setup block
collate_MIL_graph Ran
ran on a synthesized input
liupei101/advmil/dataset/GraphBatchWSI.py
code served (permissive licence) · get_code("51c8dd813a5c2578")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. 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
from torch.utils.data.dataloader import default_collate

torch.manual_seed(0)

# The function expects a batch, which is a list of elements.
# Each element is expected to be either:
# 1. A tuple (in which case only the first element is extracted)
# 2. Something that can be collated by default_collate
#
# The function transposes the batch and processes each transposed group.
# We'll create a batch with mixed types to test the logic:
# - Some elements that are tuples
# - Some elements that are simple tensors/lists

batch = [
    (torch.tensor([[1.0, 2.0, 3.0, 4.0]]), torch.tensor([0])),
    (torch.tensor([[5.0, 6.0, 7.0, 8.0]]), torch.tensor([1])),
]

ARGS = {
    "batch": batch
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list 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: none by the harness; any seed is in the setup block
get_hop_dims Ran
ran on a synthesized input
liupei101/advmil/model/model_utils.py
code served (permissive licence) · get_code("d007b9f5f20178c1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 numpy as np

torch.manual_seed(0)

# Analyzing the function:
# - get_hop_dims takes two parameters: d (a dimension, used in integer division) and hops (an integer for range)
# - d is divided by 2 repeatedly, hops times
# - The function builds a list of dimensions that halve each iteration
# - Both parameters are simple integers

ARGS = {
    "d": 64,
    "hops": 5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
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: none by the harness; any seed is in the setup block
load_backbone_param Ran
ran on a synthesized input
liupei101/advmil/model/backbone.py
code served (permissive licence) · get_code("4e2c176445471e59")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) 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
from types import SimpleNamespace

torch.manual_seed(0)

ARGS = {
    'mode': 'patch',
    'dims': [4, 8, 16, 32, 64]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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: none by the harness; any seed is in the setup block
loss_reg_l1 Ran
ran on a synthesized input
liupei101/advmil/loss/utils.py
code served (permissive licence) · get_code("96ef08c5692a223b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. 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

torch.manual_seed(0)

# The function loss_reg_l1 takes a coefficient and returns a function
# that computes L1 regularization over model parameters.
# The returned function expects model_params (an iterable of tensors)

# Create sample model parameters as a list of tensors
model_params = [
    torch.randn(4, 3),
    torch.randn(5, 2),
    torch.randn(3)
]

# Define ARGS with the coefficient parameter
ARGS = {
    'coef': 0.01
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not 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: none by the harness; any seed is in the setup block
make_noise_mlp_layer Ran
ran on a synthesized input
liupei101/advmil/model/model_utils.py
code served (permissive licence) · get_code("31e8a2a68582e09e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ModuleList. 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

torch.manual_seed(0)

# Analyzing make_noise_mlp_layer:
# - in_dim: int, used in get_hop_dims and indexing
# - out_dim: int, used in mlp_out_dims
# - noise: indexable (list/array), indexed with i up to mlp_num_layers
# - hops: int, passed to get_hop_dims
# - norm: bool, passed to make_mlp_layer
# - dropout: float, passed to make_mlp_layer

# The function builds an MLP by:
# 1. Computing hop dimensions from in_dim with get_hop_dims
# 2. Creating layers based on noise list length
# 3. Accessing noise[i] for each layer

# Let's choose small but distinct dimensions:
in_dim = 16
out_dim = 8
hops = 2  # This will create hop_dims, determining MLP structure

# get_hop_dims(16, 2) will give: [8, 4] (16//2=8, 8//2=4)
# So mlp_hid_dims = [8, 4]
# mlp_num_layers = len([8, 4]) + 1 = 3
# noise list needs 3 elements (indexed 0, 1, 2)

noise = [1, 0, 1]  # Mix of values to test the add_dim logic
norm = False
dropout = 0.25

ARGS = {
    "in_dim": in_dim,
    "out_dim": out_dim,
    "noise": noise,
    "hops": hops,
    "norm": norm,
    "dropout": dropout,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ModuleList — a ModuleList 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: none by the harness; any seed is in the setup block
prepare_dataset Ran
ran on a synthesized input
liupei101/advmil/dataset/utils.py
code served (permissive licence) · get_code("6c12bc9946ecffcb")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned WSIPatch. 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 numpy as np
from pathlib import Path
from unittest.mock import Mock

torch.manual_seed(0)

# Create mock WSIPatch class that accepts the constructor arguments
class WSIPatch:
    def __init__(self, patient_ids, path_patch, path_label, mode, read_format=None, 
                 time_format=None, time_bins=None, ratio_sampling=None, ratio_mask=None,
                 cluster_path=None, coord_path=None, graph_path=None):
        self.patient_ids = patient_ids
        self.path_patch = path_patch
        self.path_label = path_label
        self.mode = mode
        self.read_format = read_format
        self.time_format = time_format
        self.time_bins = time_bins
        self.ratio_sampling = ratio_sampling
        self.ratio_mask = ratio_mask
        self.cluster_path = cluster_path
        self.coord_path = coord_path
        self.graph_path = graph_path

# Mock the WSIPatch in the module namespace
import sys
current_module = sys.modules[__name__]
current_module.WSIPatch = WSIPatch

# Create configuration dict with all required keys
cfg = {
    'path_patch': '/mock/path/patch',
    'path_label': '/mock/path/label',
    'bcb_mode': 'patch',
    'feat_format': 'npy',
    'time_format': 'days',
    'time_bins': 10,
    'test': False,
    'path_cluster': '/mock/path/cluster',
    'path_coordx5': '/mock/path/coord',
    'path_graph': '/mock/path/graph'
}

# Create patient IDs list
patient_ids = ['patient_001', 'patient_002', 'patient_003']

# Create keyword arguments
kws = {
    'ratio_sampling': 0.8,
    'mask_ratio': 0.15
}

ARGS = {
    'patient_ids': patient_ids,
    'cfg': cfg,
    'kws': kws
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type WSIPatch — a WSIPatch output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a WSIPatch output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not 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: none by the harness; any seed is in the setup block
rank_loss Ran
ran on a synthesized input
liupei101/advmil/loss/utils.py
code served (permissive licence) · get_code("ee234d25e6f3ff5a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () 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 torch.nn.functional as F

torch.manual_seed(0)

# Create small tensors for the function
batch_size = 2
pred_t = torch.randn(batch_size, 1)
t = torch.tensor([[1.0], [3.0]])
e = torch.tensor([[1.0], [0.0]])

ARGS = {
    'pred_t': pred_t,
    't': t,
    'e': e,
    'gamma': 1,
    'norm': 'l1',
    'add_weight': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 0, dtype family float, shape () — shape () 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: none by the harness; any seed is in the setup block
recon_loss Ran
ran on a synthesized input
liupei101/advmil/loss/utils.py
code served (permissive licence) · get_code("a7bdd3621350a41c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () 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 torch.nn.functional as F

torch.manual_seed(0)

# Create small tensors for the function
batch_size = 2
dim = 4

# pred_t: predicted survival times, shape (batch_size,) or (batch_size, 1)
pred_t = torch.randn(batch_size, 1)

# t: true survival times, shape (batch_size,) or (batch_size, 1)
t = torch.randn(batch_size, 1) + 5.0  # offset to make times positive

# e: event indicator (0 or 1), shape (batch_size,) or (batch_size, 1)
e = torch.tensor([[1.0], [0.0]])

# alpha: regularization parameter, float in [0, 1]
alpha = 0.5

# gamma: margin parameter for censored loss
gamma = 1.0

# norm: loss normalization type, either 'l1' or 'l2'
norm = 'l1'

# cur_alpha: optional override for alpha, can be None or a float
cur_alpha = None

ARGS = {
    'pred_t': pred_t,
    't': t,
    'e': e,
    'alpha': alpha,
    'gamma': gamma,
    'norm': norm,
    'cur_alpha': cur_alpha
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 0, dtype family float, shape () — shape () 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: none by the harness; any seed is in the setup block
sequence2square Ran
ran on a synthesized input
liupei101/advmil/model/backbone_utils.py
code served (permissive licence) · get_code("2da5595b8297945e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) 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

torch.manual_seed(0)

# x: [B, N, C] tensor
# s: integer for square dimension
# The function reshapes [B, N, C] -> [B*(N/s^2), C, s, s]
# So N must be divisible by s^2

B = 2  # batch size
s = 4  # square dimension
N = s * s * 3  # sequence length, must be divisible by s^2
C = 5  # channels

x = torch.randn(B, N, C)

ARGS = {
    "x": x,
    "s": s,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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: none by the harness; any seed is in the setup block
Model_Zoo Not yet run
unverified (harvested, no recorded run)
liupei101/advmil/model/backbone.py
code served (permissive licence) · get_code("57113a306fd5f9e7")
How it ran

no invocation recorded.

load_backbone Not yet run
unverified (harvested, no recorded run)
liupei101/advmil/model/backbone.py
code served (permissive licence) · get_code("5a8d62b0d3d40685")
How it ran

no invocation recorded.

make_efficient_mlp_layer Not yet run
unverified (harvested, no recorded run)
liupei101/advmil/model/model_utils.py
code served (permissive licence) · get_code("0e4e4f4949f86e19")
How it ran

no invocation recorded.

posemb_sincos_2d Not yet run
unverified (harvested, no recorded run)
liupei101/advmil/model/backbone_utils.py
code served (permissive licence) · get_code("a81a27cc1f5ac5c9")
How it ran

no invocation recorded.

square2sequence Not yet run
unverified (harvested, no recorded run)
liupei101/advmil/model/backbone_utils.py
code served (permissive licence) · get_code("8d269c3586d4d722")
How it ran

no invocation recorded.

Also present in other papers' code

Of 15 samples lifted from this paper's linked repositories, 15 carry a function identity and 0 do not. Of the 15 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 15 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

The survival analysis on histological whole-slide images (WSIs) is one of the most important means to estimate patient prognosis. Although many weakly-supervised deep learning models have been developed for gigapixel WSIs, their potential is generally restricted by classical survival analysis rules and fully-supervised learning requirements. As a result, these models provide patients only with a completely-certain point estimation of time-to-event, and they could only learn from the labeled WSI data currently at a small scale. To tackle these problems, we propose a novel adversarial multiple instance learning (AdvMIL) framework. This framework is based on adversarial time-to-event modeling, and integrates the multiple instance learning (MIL) that is much necessary for WSI representation learning. It is a plug-and-play one, so that most existing MIL-based end-to-end methods can be easily upgraded by applying this framework, gaining the improved abilities of survival distribution estimation and semi-supervised learning. Our extensive experiments show that AdvMIL not only could often bring performance improvement to mainstream WSI survival analysis methods at a relatively low computational cost, but also enables these methods to effectively utilize unlabeled data via semi-supervised learning. Moreover, it is observed that AdvMIL could help improving the robustness of models against patch occlusion and two representative image noises. The proposed AdvMIL framework could promote the research of survival analysis in computational pathology with its novel adversarial MIL paradigm.

For agents

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

get_harvested_code_for_paper("2212.06515")
get_code_for_paper("2212.06515")
have("2212.06515")

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

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

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

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

Connect an agent — have() is free.