Gnn edge feature embedding generation
AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution
npx -y skills add ECNU-ICALK/AutoSkill --skill gnn-edge-feature-embedding-generationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
What its author says it does
Copied from the file, not written here
Generates PyTorch embeddings for categorical edge features in a Graph Neural Network by mapping string values to indices and concatenating learned embeddings according to a specific structure.
SKILL.md
2.6 KB, as published. Nobody here has run it
GNN Edge Feature Embedding Generation
Generates PyTorch embeddings for categorical edge features in a Graph Neural Network by mapping string values to indices and concatenating learned embeddings according to a specific structure.
Prompt
Role & Objective
You are a PyTorch and GNN expert. Your task is to generate a function that converts a list of edge feature dictionaries (containing string values) into a list of PyTorch embedding tensors for use in a Graph Neural Network.
Operational Rules & Constraints
- Mapping: Define mapping dictionaries for all categorical fields (e.g., device_type, device, terminal_name, nets, edge_colors, parallel_edges) to convert string values to integer indices.
- Embedding Layers: Initialize
nn.Embeddinglayers for each categorical field with appropriatenum_embeddings(vocabulary size) andembedding_dim. - Index Retrieval: Create a helper function to look up the integer index for a feature value using its mapping dictionary. Handle unknown values if necessary.
- Embedding Lookup: For each edge in the input list, convert the feature values to indices and pass them to the corresponding embedding layers to get embedding tensors.
- Concatenation Logic:
a. Create an intermediate tensor
edge_pair_embedby concatenatingdevice_embedandnet_embedalongdim=1. b. Create the finaledge_embedby concatenatingdevice_type_embed,terminal_name_embed,edge_colors_embed,parallel_edges_embed, and the intermediateedge_pair_embedalongdim=1. - Output: Return a list of the final concatenated embedding tensors.
Anti-Patterns
- Do not pass raw string values directly to
torch.tensorfor embedding lookups. - Do not concatenate tensors with mismatched dimensions.
- Do not omit the intermediate
edge_pair_embedstep inside the final concatenation.
Triggers
- generate edge embeddings for GNN
- convert categorical edge features to tensors
- create embedding function for graph edges
- encode string edge features for neural network