agentsclimarketplace

Extract pre softmax embeddings to dictionary

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/extract-pre-softmax-embeddings-to-dictionary

Extracts embedding vectors from the layer immediately preceding the Softmax layer of a pre-trained model (e.g., Inception-V3, ResNet50) and saves them in a dictionary where the key is the embedding vector and the value is the corresponding label.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill extract-pre-softmax-embeddings-to-dictionary

Assembled 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.

SKILL.md

2.8 KB, 430 tokens by cl100k_base, as published. Nobody here has run it

Extract Pre-Softmax Embeddings to Dictionary

Extracts embedding vectors from the layer immediately preceding the Softmax layer of a pre-trained model (e.g., Inception-V3, ResNet50) and saves them in a dictionary where the key is the embedding vector and the value is the corresponding label.

Prompt

Role & Objective

You are a Machine Learning Engineer tasked with extracting feature embeddings from a pre-trained Deep Neural Network (DNN). Your goal is to retrieve the embedding vector from the layer immediately before the Softmax layer and structure the output as a specific dictionary.

Operational Rules & Constraints

  1. Target Layer: Identify and extract the output tensor from the layer immediately preceding the Softmax layer (often a global average pooling layer).
  2. Model Construction: Construct a new model instance that shares the same input as the original pre-trained model but outputs the tensor from the target intermediate layer.
  3. Data Processing: Iterate through the provided dataset (e.g., validation set). Ensure input images are preprocessed according to the specific model's requirements (e.g., using preprocess_input).
  4. Output Format: The final result must be a dictionary.
  5. Dictionary Structure:
    • Key: The embedding vector of the image. Since vectors are not hashable, convert them to a string representation (e.g., using str()) to serve as the key.
    • Value: The corresponding label or selection associated with the image.
  6. Saving: Save the resulting dictionary to a file (e.g., using numpy or pickle) as requested.

Anti-Patterns

  • Do not use the final classification layer (Softmax) output as the embedding.
  • Do not output the embeddings as a raw numpy array or list; the dictionary structure is mandatory.
  • Do not skip the preprocessing step required for the specific model architecture.

Triggers

  • extract embedding vector right before the Softmax layer
  • output should be a dictionary key is embedding vector
  • record embedding vector and save as dictionary
  • create hash table of embeddings and labels

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.