File size: 1,449 Bytes
c72c956
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
license: cc-by-nc-4.0
library_name: pytorch
tags:
  - time-series
  - ecg
  - representation-learning
---

# LeNEPA encoder (balanced, encoder-only)

This repository contains an **encoder-only** LeNEPA checkpoint exported to `safetensors` for minimal inference.

What is included:

- `lenepa_encoder.safetensors`**encoder weights only** (no projector, no training/probe state)
- `inference.py` — minimal end-to-end inference (no Hydra, no W&B)
- `lenepa_encoder_config.json` — fixed IO + architecture contract
- `provenance.json` — original `.pt` checkpoint path + W&B URL

## IO contract

Inputs:

- `x_waveform`: `torch.float32` with shape `[B, 1, 5000]`
- sampling frequency: `500` Hz
- channels: `["I"]` (so `C=1`)

Outputs:

- `patch_tokens`: `[B, 200, 192]` (post-final-norm tokens)
- `embedding`: `[B, 192]` (mean pooled over tokens)

## Usage

Smoke test (loads `lenepa_encoder.safetensors` from the current directory and prints output shapes):

```bash
python inference.py
```

Programmatic usage:

```python
from pathlib import Path

import torch

from inference import encode_lenepa, load_lenepa_encoder

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = load_lenepa_encoder(weights_path=Path("lenepa_encoder.safetensors"), device=device)
x = torch.randn(2, 1, 5000, device=device, dtype=torch.float32)  # [B, C, L]
out = encode_lenepa(model=model, x_waveform=x)
print(out.embedding.shape)
```