SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2303.11073 · 2023

Discovering Interpretable Directions in the Semantic Latent Space of Diffusion Models

arXiv · PDF · Open in the Atlas

Code that ran

3 of 5 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, 1 violated it and 0 have no contract verdict; 2 failures of our instrument; 2 no recorded run), measured 2026-11-22; 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/2303.11073.json · badge: /api/ran/2303.11073.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
renhaa/semantic-diffusion canonical (classifier label)
classifier basis: classifier_2025
3 ran · 2 no recorded run
FunctionStatusWhere it lives
fix_sign_ambiguity Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
renhaa/semantic-diffusion/editing/pca.py
code served (permissive licence) · get_code("42682243422c8c83")
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) and returned Tensor, ndim 1, dtype family float, shape (4,) 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

torch.manual_seed(0)

# The function takes a single parameter 'x' which is a tensor
# It checks if the first element (x[0]) is negative using torch.sign()
# If negative, it returns -x, otherwise returns x
# So x needs to be a tensor with at least one element

x = torch.randn(4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 1, dtype family float, shape (4,) — shape (4,) 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
forward_ResnetBlock2D Ran
ran; our contract draft was wrong, not the code
renhaa/semantic-diffusion/semanticdiffusion.py
code served (permissive licence) · get_code("679959347d2e3c25")
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) 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)

class MockNorm(nn.Module):
    def __init__(self, num_channels):
        super().__init__()
        self.num_channels = num_channels
    
    def forward(self, x):
        return x

class MockConv2d(nn.Module):
    def __init__(self, in_channels, out_channels):
        super().__init__()
        self.in_channels = in_channels
        self.out_channels = out_channels
    
    def forward(self, x):
        batch, channels, height, width = x.shape
        return torch.randn(batch, self.out_channels, height, width)

class MockUpsample(nn.Module):
    def forward(self, x):
        batch, channels, height, width = x.shape
        return torch.randn(batch, channels, height * 2, width * 2)

class MockDownsample(nn.Module):
    def forward(self, x):
        batch, channels, height, width = x.shape
        return torch.randn(batch, channels, height // 2, width // 2)

class MockResnetBlock2D(nn.Module):
    def __init__(self):
        super().__init__()
        self.norm1 = MockNorm(4)
        self.norm2 = MockNorm(4)
        self.nonlinearity = nn.ReLU()
        self.upsample = None
        self.downsample = None
        self.conv1 = MockConv2d(4, 4)
        self.conv2 = MockConv2d(4, 4)
        self.time_emb_proj = nn.Linear(4, 4)
        self.dropout = nn.Dropout(0.1)
    
    def forward(self, input_tensor, temb, inject_into_botleneck=None):
        hidden_states = input_tensor
        hidden_states = self.norm1(hidden_states)
        hidden_states = self.nonlinearity(hidden_states)
        if self.upsample is not None:
            if hidden_states.shape[0] >= 64:
                input_tensor = input_tensor.contiguous()
                hidden_states = hidden_states.contiguous()
            input_tensor = self.upsample(input_tensor)
            hidden_states = self.upsample(hidden_states)
        elif self.downsample is not None:
            input_tensor = self.downsample(input_tensor)
            hidden_states = self.downsample(hidden_states)
        hidden_states = self.conv1(hidden_states)
        if temb is not None:
            temb = self.time_emb_proj(self.nonlinearity(temb))[:, :, None, None]
            hidden_states = hidden_states + temb
        hidden_states = self.norm2(hidden_states)
        bottleneck = hidden_states.clone()
        if not inject_into_botleneck is None:
            hidden_states = bottleneck + inject_into_botleneck
        hidden_states = self.nonlinearity(hidden_states)
        hidden_states = self.dropout(hidden_states)
        hidden_states = self.conv2(hidden_states)
        output_tensor = input_tensor + hidden_states
        return (output_tensor, bottleneck)

model = MockResnetBlock2D()

input_tensor = torch.randn(2, 4, 8, 8)
temb = torch.randn(2, 4)
inject_into_botleneck = torch.randn(2, 4, 8, 8)

ARGS = {
    "self": model,
    "input_tensor": input_tensor,
    "temb": temb,
    "inject_into_botleneck": inject_into_botleneck,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
make_sure_vecs_point_in_same_direction Ran
ran, violated the contract we drafted
renhaa/semantic-diffusion/editing/pca.py
code served (permissive licence) · get_code("948969a8445d5846")
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) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 4) 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

torch.manual_seed(0)

# The function expects V to be a tensor with shape (batch_size, num_vectors, vector_dim)
# It iterates through V[j, 0] and V[j, i] and computes dot products
# Each V[j, i] should be a 1D tensor (vector)

# Create a small tensor: batch_size=2, num_vectors=3, vector_dim=4
V = torch.randn(2, 3, 4)

ARGS = {
    "V": V
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 3, dtype family float, shape (2, 3, 4) — shape (2, 3, 4) 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
make_variations Not yet run
unverified (harvested, no recorded run)
renhaa/semantic-diffusion/editing/pca.py
code served (permissive licence) · get_code("e4b95e4cd48e17c5")
How it ran

no invocation recorded.

mid_block_forward Not yet run
unverified (harvested, no recorded run)
renhaa/semantic-diffusion/semanticdiffusion.py
code served (permissive licence) · get_code("ab6d6e56292cdb0e")
How it ran

no invocation recorded.

Also present in other papers' code

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

Repositories linked to this paper

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

Abstract

Denoising Diffusion Models (DDMs) have emerged as a strong competitor to Generative Adversarial Networks (GANs). However, despite their widespread use in image synthesis and editing applications, their latent space is still not as well understood. Recently, a semantic latent space for DDMs, coined `$h$-space', was shown to facilitate semantic image editing in a way reminiscent of GANs. The $h$-space is comprised of the bottleneck activations in the DDM's denoiser across all timesteps of the diffusion process. In this paper, we explore the properties of h-space and propose several novel methods for finding meaningful semantic directions within it. We start by studying unsupervised methods for revealing interpretable semantic directions in pretrained DDMs. Specifically, we show that global latent directions emerge as the principal components in the latent space. Additionally, we provide a novel method for discovering image-specific semantic directions by spectral analysis of the Jacobian of the denoiser w.r.t. the latent code. Next, we extend the analysis by finding directions in a supervised fashion in unconditional DDMs. We demonstrate how such directions can be found by relying on either a labeled data set of real images or by annotating generated samples with a domain-specific attribute classifier. We further show how to semantically disentangle the found direction by simple linear projection. Our approaches are applicable without requiring any architectural modifications, text-based guidance, CLIP-based optimization, or model fine-tuning.

For agents

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

get_harvested_code_for_paper("2303.11073")
get_code_for_paper("2303.11073")
have("2303.11073")

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

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

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

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

Connect an agent — have() is free.