agentsclimarketplace

Resnet architecture modification for dimensionality control

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/resnet-architecture-modification-for-dimensionality-control

Use when your task requires a pretrained convolutional encoder (ResNet18) to produce fixed-size representation vectors of a specific dimensionality (e.g., 512 dimensions) rather than the default output size.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill resnet-architecture-modification-for-dimensionality-control

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

  • 14 stars14 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

6.4 KB, 960 tokens by cl100k_base, as published. Nobody here has run it

ResNet Architecture Modification for Dimensionality Control

License: restricted — no clear open-source license detected for the underlying tool; verify licensing before commercial use or redistribution. <!-- asb-license-banner -->

Summary

Modify a ResNet18 base architecture to output fixed-dimensional representation vectors by replacing or reconfiguring the final fully connected layer. This skill is essential for constraining encoder output to match downstream pipeline requirements (e.g., 512-dimensional vectors for contrastive learning in mass spectrometry imaging).

When to use

Your task requires a pretrained convolutional encoder (ResNet18) to produce fixed-size representation vectors of a specific dimensionality (e.g., 512 dimensions) rather than the default output size. This is typical when integrating ResNet into a contrastive learning pipeline where consistent vector dimensionality is required for projection and prediction modules.

When NOT to use

  • The encoder output dimensionality is already correctly sized for your downstream modules
  • You need a pre-trained ResNet18 with frozen weights; architectural modification may require retraining
  • Your input images are not in standard image format or require specialized preprocessing beyond standard augmentation

Inputs

  • ResNet18 model definition (PyTorch or TensorFlow)
  • Target output dimensionality (integer, e.g. 512)
  • Sample input images or dummy tensors (for shape validation)

Outputs

  • Modified ResNet18 encoder with reconfigured final layer
  • Validated output tensor of shape [batch_size, target_dimensionality]
  • Confirmation of numerical correctness for forward passes

How to apply

Start with a standard ResNet18 architecture from PyTorch or TensorFlow. Identify the final fully connected layer (typically outputting 1000 classes for ImageNet) and replace or reconfigure it to output the target dimensionality (e.g., 512). This is done by modifying the in_features and out_features parameters of the final linear layer or by adding a custom adapter layer. After modification, instantiate the encoder and pass test input tensors (matching the expected image shape) through a forward pass to verify the output shape matches the target dimensionality. Validate that both the tensor shape and numerical values are correct before integrating into the full pipeline.

Related tools

  • ResNet18 (Base convolutional architecture whose final fully connected layer is reconfigured to output 512-dimensional representation vectors)
  • PyTorch (Framework for defining and instantiating the modified ResNet18 model and validating forward passes)
  • TensorFlow (Alternative framework for defining and instantiating the modified ResNet18 model)

Evaluation signals

  • Output tensor shape is exactly [batch_size, 512] for batch_size augmented images
  • Forward pass completes without shape mismatch errors or dimension incompatibilities
  • Numerical output values are in expected range (e.g., not NaN or inf) after initialization
  • Two sequential forward passes of two distinct augmented images produce two distinct 512-dimensional vectors
  • Integration into the downstream Projection and Prediction modules completes without shape errors

Limitations

  • Modifying the final layer from 1000 to 512 dimensions loses ImageNet pretraining alignment; retraining or fine-tuning may be necessary for optimal performance
  • The modification is specific to ResNet18; other backbone architectures (ResNet50, DenseNet, etc.) require analogous but distinct layer reconfigurations
  • No guidance is provided in the source material on whether the encoder should remain frozen or be trained end-to-end with the rest of the DeepION pipeline

Evidence

  • [other] Configure the encoder to output 512-dimensional vectors by modifying the final fully connected layer: "Configure the encoder to output 512-dimensional vectors by modifying the final fully connected layer."
  • [other] Implement parameter sharing by instantiating a single ResNet18 model and passing both augmented images sequentially through the same encoder instance: "Implement parameter sharing by instantiating a single ResNet18 model and passing both augmented images sequentially through the same encoder instance."
  • [other] Verify that forward passes of two augmented images produce two distinct 512-dimensional representation vectors from the shared encoder: "Verify that forward passes of two augmented images produce two distinct 512-dimensional representation vectors from the shared encoder."
  • [readme] Two augmented images are propagated through a pair of ResNet18-based encoders that shared parameters, then output two 512-dimensional representation vectors: "Two augmented images are propagated through a pair of ResNet18-based encoders that shared parameters, then output two 512-dimensional representation vectors"
  • [other] Validate the output tensor shapes and numerical correctness before integration into the full DeepION pipeline: "Validate the output tensor shapes and numerical correctness before integration into the full DeepION pipeline."

What ships with it

Read from the repository

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

Keep looking

Skills are one crate of 326,852. 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.