No project description provided
Project description
clipscope
usage
import PIL
from clipscope import ConfiguredViT, TopKSAE
device='cpu'
filename_in_hf_repo = "22_resid/1200013184.pt"
sae = TopKSAE.from_pretrained(checkpoint=filename_in_hf_repo, device=device)
locations = [(22, 'resid')]
transformer = ConfiguredViT(locations, device=device)
input = PIL.Image.new("RGB", (224, 224), (0, 0, 0)) # black image for testing
activations = transformer.all_activations(input)[locations[0]] # (1, 257, 1024)
assert activations.shape == (1, 257, 1024)
activations = activations[:, 0] # just the cls token
# alternatively flatten the activations
# activations = activations.flatten(1)
print('activations shape', activations.shape)
output = sae.forward_verbose(activations)
print('output keys', output.keys())
print('latent shape', output['latent'].shape) # (1, 65536)
print('reconstruction shape', output['reconstruction'].shape) # (1, 1024)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
clipscope-0.1.8.tar.gz
(3.9 kB
view details)
Built Distribution
File details
Details for the file clipscope-0.1.8.tar.gz
.
File metadata
- Download URL: clipscope-0.1.8.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dc81e469a07d3538b84254120372c5537c96a4c094f70a4672a243e51329475 |
|
MD5 | 03a2dd651767541795e6c0bbb15f48c5 |
|
BLAKE2b-256 | edc588d15c8926fc2f0440c91f7cd524e817aa0c18381b1c6d246d9e22f87744 |
File details
Details for the file clipscope-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: clipscope-0.1.8-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 380a9eb7bd18dc474b27325ae8df3e2ee8fefdda209399e424a8c4285913da4d |
|
MD5 | b7849cdc88e59fb63231956767e5cb04 |
|
BLAKE2b-256 | 0486e2f5dbed7be2bf39778c432fae0f84ba4224f6e203ca4702d284a0e7f6b8 |