Dataset Viewer
Auto-converted to Parquet Duplicate
Search is not available for this dataset
image
array 3D
label
class label
2 classes
[[[0.0,0.11789826303720474,0.0,0.0],[0.0,0.0,0.11789826303720474,0.0],[0.11789826303720474,0.1178982(...TRUNCATED)
1Diamond
[[[0.0,0.04224588721990585,0.0,0.0],[0.0,0.0,0.04224588721990585,0.0],[0.04224588721990585,0.0422458(...TRUNCATED)
1Diamond
[[[0.0,0.09073677659034729,0.0,0.0],[0.0,0.0,0.09073677659034729,0.0],[0.09073677659034729,0.0907367(...TRUNCATED)
1Diamond
[[[0.0,0.13160867989063263,0.0,0.0],[0.0,0.0,0.13160867989063263,0.0],[0.13160867989063263,0.1316086(...TRUNCATED)
1Diamond
[[[0.0,0.062067944556474686,0.0,0.0],[0.0,0.0,0.062067944556474686,0.0],[0.062067944556474686,0.0620(...TRUNCATED)
0X
[[[0.0,0.2526882588863373,0.0,0.0],[0.0,0.0,0.2526882588863373,0.0],[0.2526882588863373,0.2526882588(...TRUNCATED)
1Diamond
[[[0.0,0.0028587651904672384,0.0,0.0],[0.0,0.0,0.0028587651904672384,0.0],[0.0028587651904672384,0.0(...TRUNCATED)
1Diamond
[[[0.0,0.021136799827218056,0.0,0.0],[0.0,0.0,0.021136799827218056,0.0],[0.021136799827218056,0.0211(...TRUNCATED)
1Diamond
[[[0.0,0.2621175944805145,0.0,0.0],[0.0,0.0,0.2621175944805145,0.0],[0.2621175944805145,0.2621175944(...TRUNCATED)
1Diamond
[[[0.0,0.25055384635925293,0.0,0.0],[0.0,0.0,0.25055384635925293,0.0],[0.25055384635925293,0.2505538(...TRUNCATED)
1Diamond
End of preview. Expand in Data Studio

Dataset Card for SyntheticPatterns:

  • Curated by: Daniel Sampaio Goncalves (dataset generated using SyntheticPatterns)
  • Language(s) (NLP): Not applicable
  • License: Apache 2.0.

Generation

This dataset consists of synthetic binary patch patterns with 2 classes ("X" and "Diamond") generated using the SyntheticPatterns package. It is designed to explore permutation-aware neural architectures and train them to perform distinct pattern recognition.

The idea

The dataset is composed of tensors with shape [N, P, P], where N represents the number of unique patterns and P defines the semantic expression.

pattern_example

These patterns were intentionally designed to encode semantic content through controlled intensity modulation. By assigning higher values to a specific subset of patterns, a clear signal-to-baseline distinction was established.

Specifically, the intensity values were generated by applying a fixed permutation (unique to each class) to reshuffle the patterns across the grid, followed by the creation of a target geometric configuration by increasing the intensity of the patterns forming that shape. The data was then permuted back to the same shared original sequence for each class.

Consequently, while the transformed patterns appear structurally random, they retain a latent geometric identity that re-emerges under the correct permutation. This embedding strategy is intended to train models in learning permutation-aware representations and test their ability to recover latent structures from apparent disorder.

Example patterns: an X and a Diamond

Contents

Config Folder Column Tensor shape Meaning
default data/ image [4096, 4, 4], float32 4096 patches of 4×4
default data/ label [2],int64 X (0) or Diamond (1)
permutation_tensors permutation_tensors/ image [4096],int64 tensors that permutes the patches to their specific shape
permutation_tensors permutation_tensors/ label [2], int64 X (0) or Diamond (1)

The repo also holds pattern_book/pattern_book.csv, with columns Name (int), pattern (4×4 tensors stored as a list of strings) and Label (list stored as a string).

Usage example: download, permute and visualize the ground truth shapes

import torch
import torchvision

from datasets import load_dataset
from matplotlib import pyplot as plt

# # download the dataset from hf
synthetic_patterns = load_dataset("daniel-sampaio-goncalves/SyntheticPatterns").with_format("torch")

# load the permutation tensors
permutation_tensors = load_dataset("daniel-sampaio-goncalves/SyntheticPatterns", "permutation_tensors").with_format("torch")

# Extract the first x and diamond example:
x_index = next( 
    index for index, label in enumerate(synthetic_patterns["train"]["label"]) 
    if label == 0 
    )

dia_index = next(
    index for index, label in enumerate(synthetic_patterns["train"]["label"]) 
    if label == 1 
    )

x_tensor=synthetic_patterns["train"][x_index]["image"]
dia_tensor=synthetic_patterns["train"][dia_index]["image"]

# Extract the x and diamond permutation tensors
x_permut=permutation_tensors["train"][0]["image"]
dia_permut=permutation_tensors["train"][1]["image"]

######## Visualize ########

# to visualize the patterns as image we can use a small matplotlib function (and unsqueeze a grey channel in the process)
def show_grid(
    tensor:torch.Tensor, 
    nrow=None, 
    figsize=(12, 12), 
    ax=None, 
    show:bool=True
    )->None|plt.figure.Figure:
        """
        Display a batch of grayscale or RGB images as a single grid. tensor can be cuda or cpu and will be ploted using cpu

        Args:
            tensor (torch.Tensor): Image batch of shape [B,P,P], [B,1,P,P], or [B,3,P,P].
            nrow (int, optional): Number of images per row. Defaults to sqrt(B).
            figsize (tuple, optional): Matplotlib figure size.
            ax (matplotlib.axes.Axes, optional): Existing axes on which to draw the image grid. If None, a new figure and axes are created.
            show (bool, optional): Whether to display the figure. Defaults to True.
        Returns:
            None or matplotlib.figure.Figure
        """

        # [B,P,P] -> [B,1,P,P]
        if tensor.ndim == 3:
            tensor = tensor.unsqueeze(1)

        B, C, _, _ = tensor.shape

        if nrow is None:
            nrow = int(torch.sqrt(torch.tensor(B)).item())

        grid = torchvision.utils.make_grid(
            tensor,
            nrow=nrow,
            pad_value=0,
            normalize=False,
        )

        created_figure = False
        if ax is None:
            fig, ax = plt.subplots(figsize=figsize)
            created_figure = True

        ax.axis("off")


        if C == 1:
            ax.imshow(
                grid[0].cpu(),
                cmap="Greys",
                vmin=0,
                vmax=1,
            )
        else:

            ax.imshow(
                grid.permute(1, 2, 0).cpu()
            )

        if show  and created_figure:
            plt.show()
        if not show and created_figure:

            plt.close(fig) 
            return fig     

# Visualize the tensor's embedded ground truth
show_grid(x_tensor[x_permut]) 
show_grid(dia_tensor[dia_permut])

Format and display the pattern codebook:

import torch
import pandas as pd
import ast

from huggingface_hub import hf_hub_download


# download the pattern code_book:
path = hf_hub_download(
    repo_id="daniel-sampaio-goncalves/SyntheticPatterns",
    filename="pattern_book/pattern_book.csv",
    repo_type="dataset",
)

df_codebook = pd.read_csv(path)

# format the df to the correct types
def load_pattern_csv(df:pd.DataFrame):
    """
    Reads a CSV file and performs the following transformations:
        - Converts the 'Name' column to integers.
        - Transforms the 'pattern' column from string representations to torch.Tensor objects.
        - Converts the 'Label' column from string representations to Python lists.

    Args:
        df (DataFrame [str,str,str]): a pandas dataframe with the pattern codebook ["Name", "pattern (Tensors)", "Label"].

    Returns:
        pd.DataFrame: A DataFrame with correctly typed 'Name' as str, 'pattern' as torch.Tensor, and 'Label' as list[str,str] columns.

    """

    # Name as int
    df["Name"] = df["Name"].astype(int)

    # pattern string -> torch.Tensor
    df["pattern"]=df["pattern"].apply(lambda x: torch.tensor(ast.literal_eval(x))) # type: ignore

    # Label string -> list
    df["Label"] = df["Label"].apply(ast.literal_eval)
    
    return df
    
df_codebook = load_pattern_csv(df_codebook)
# display to df
display(df_codebook)


#### To extract the tensors and visualize them: #####

# convert binary patterns into a tensor stack of shape [4096,4,4]:
codebook_patterns=torch.stack(df_codebook["pattern"].tolist())

# use the 'show_grid' function from the previous code section to visualize
show_grid(codebook_patterns)

License

Apache 2.0.

Citations

If you find this resource useful, a citation or acknowledgment is greatly appreciated. Thank you for supporting this work!

Dataset

Sampaio Goncalves, D. (2026). SyntheticPatterns (Version 1.0.0) [Data set]. Hugging Face. https://huggingface.co/datasets/daniel-sampaio-goncalves/SyntheticPatterns

Software

Sampaio Goncalves, D. (2026). SyntheticPatterns (Version 1.0.0) [Computer software]. GitHub. https://github.com/daniel-sampaio-goncalves/syntheticpatterns

Downloads last month
205