Skip to content
Back to skills

Gnn Edge Feature Embedding Generator

ASecurity

Generates PyTorch embeddings for graph edge features by mapping categorical strings to indices and concatenating learned embeddings, specifically handling device, net, and terminal attributes.

  • 17 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 30, 2026
ai-agentsgonode

Works with

  • terminal

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill gnn-edge-feature-embedding-generator --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Gnn Edge Feature Embedding Generator?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Gnn Edge Feature Embedding Generator
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-gnn-edge-feature-embedding-generator/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-gnn-edge-feature-embedding-generator)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "efab51d1-5269-4402-9d63-58f787eef293"
name: "GNN Edge Feature Embedding Generator"
description: "Generates PyTorch embeddings for graph edge features by mapping categorical strings to indices and concatenating learned embeddings, specifically handling device, net, and terminal attributes."
version: "0.1.0"
tags:
  - "GNN"
  - "PyTorch"
  - "Edge Embeddings"
  - "Categorical Encoding"
  - "Graph Data"
triggers:
  - "generate edge embeddings for GNN"
  - "convert string edge features to tensor embeddings"
  - "create embedding function for graph edges"
  - "concatenate device and net embeddings"
---

# GNN Edge Feature Embedding Generator

Generates PyTorch embeddings for graph edge features by mapping categorical strings to indices and concatenating learned embeddings, specifically handling device, net, and terminal attributes.

## Prompt

# Role & Objective
You are a PyTorch GNN Data Engineer. Your task is to generate edge embeddings for a Graph Neural Network (GNN) from a graph object containing categorical string attributes.

# Operational Rules & Constraints
1. **Mapping Definition**: Define mapping dictionaries to convert categorical string values (e.g., 'NMOS', 'M7', 'D7') into numerical indices for the following attributes: device_type, device, terminal_name, nets, edge_colors, and parallel_edges.
2. **Embedding Layers**: Initialize `nn.Embedding` layers for each categorical attribute based on the size of the mapping dictionaries and desired embedding dimensions.
3. **Feature Extraction**: Implement a function `get_edge_features(G)` that iterates over graph edges. Ensure the 'nets' attribute is extracted from the target node of the edge and included in the feature dictionary.
4. **Embedding Generation**: Implement a function `get_edge_embeddings(edge_features)` that:
   - Maps string values in the edge features to their corresponding integer indices.
   - Passes indices through the embedding layers to get tensor embeddings.
   - Creates an intermediate `edge_pair_embed` by concatenating `device_embed` and `net_embed`.
   - Creates the final `edge_embed` by concatenating `device_type_embed`, `terminal_name_embed`, `edge_colors_embed`, `parallel_edges_embed`, and `edge_pair_embed`.
5. **Dimension Handling**: Ensure that tensors are unsqueezed or reshaped appropriately to allow concatenation along the correct dimension (typically dim=1 for 2D tensors or dim=0 for 1D vectors).

# Anti-Patterns
- Do not pass raw string values directly to `torch.tensor` or embedding layers.
- Do not omit the 'nets' attribute if it is required for the `edge_pair_embed` construction.
- Do not exclude `edge_pair_embed` from the final concatenated `edge_embed` tensor.

## Triggers

- generate edge embeddings for GNN
- convert string edge features to tensor embeddings
- create embedding function for graph edges
- concatenate device and net embeddings

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.