Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- pytorch
|
| 4 |
+
- safetensors
|
| 5 |
+
license: mit
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
# dm_qwen4b_emulator
|
| 9 |
+
|
| 10 |
+
2-layer MLP.
|
| 11 |
+
|
| 12 |
+
## Config
|
| 13 |
+
- `input_dim`: 6
|
| 14 |
+
- `hidden_dim`: 256
|
| 15 |
+
- `output_dim`: 3
|
| 16 |
+
|
| 17 |
+
## Usage
|
| 18 |
+
|
| 19 |
+
```python
|
| 20 |
+
import torch
|
| 21 |
+
import torch.nn as nn
|
| 22 |
+
from safetensors.torch import load_file
|
| 23 |
+
from huggingface_hub import hf_hub_download
|
| 24 |
+
|
| 25 |
+
class MLP(nn.Module):
|
| 26 |
+
def __init__(self, input_dim, hidden_dim, output_dim):
|
| 27 |
+
super().__init__()
|
| 28 |
+
self.mlp = nn.Sequential(
|
| 29 |
+
nn.Linear(input_dim, hidden_dim),
|
| 30 |
+
nn.LayerNorm(hidden_dim),
|
| 31 |
+
nn.ReLU(),
|
| 32 |
+
nn.Linear(hidden_dim, hidden_dim),
|
| 33 |
+
nn.LayerNorm(hidden_dim),
|
| 34 |
+
nn.ReLU(),
|
| 35 |
+
nn.Linear(hidden_dim, output_dim),
|
| 36 |
+
)
|
| 37 |
+
def forward(self, x):
|
| 38 |
+
return self.mlp(x)
|
| 39 |
+
|
| 40 |
+
path = hf_hub_download("chewwt/dm_qwen4b_emulator", "model.safetensors")
|
| 41 |
+
model = MLP(input_dim=6, hidden_dim=256, output_dim=3)
|
| 42 |
+
model.load_state_dict(load_file(path))
|
| 43 |
+
model.eval()
|
| 44 |
+
|
| 45 |
+
with torch.no_grad():
|
| 46 |
+
out = model(torch.randn(1, 6))
|
| 47 |
+
```
|