Upload folder using huggingface_hub
Browse files
del_model/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: transformers
|
3 |
+
tags:
|
4 |
+
- generated_from_trainer
|
5 |
+
datasets:
|
6 |
+
- crispr_data
|
7 |
+
model-index:
|
8 |
+
- name: SX_ispymac_Lindel_del
|
9 |
+
results: []
|
10 |
+
---
|
11 |
+
|
12 |
+
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
13 |
+
should probably proofread and complete it, then remove this comment. -->
|
14 |
+
|
15 |
+
# SX_ispymac_Lindel_del
|
16 |
+
|
17 |
+
This model is a fine-tuned version of [](https://huggingface.co/) on the crispr_data dataset.
|
18 |
+
It achieves the following results on the evaluation set:
|
19 |
+
- Loss: 463.4343
|
20 |
+
|
21 |
+
## Model description
|
22 |
+
|
23 |
+
More information needed
|
24 |
+
|
25 |
+
## Intended uses & limitations
|
26 |
+
|
27 |
+
More information needed
|
28 |
+
|
29 |
+
## Training and evaluation data
|
30 |
+
|
31 |
+
More information needed
|
32 |
+
|
33 |
+
## Training procedure
|
34 |
+
|
35 |
+
### Training hyperparameters
|
36 |
+
|
37 |
+
The following hyperparameters were used during training:
|
38 |
+
- learning_rate: 0.001
|
39 |
+
- train_batch_size: 100
|
40 |
+
- eval_batch_size: 100
|
41 |
+
- seed: 63036
|
42 |
+
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
43 |
+
- lr_scheduler_type: linear
|
44 |
+
- lr_scheduler_warmup_ratio: 0.05
|
45 |
+
- num_epochs: 30.0
|
46 |
+
|
47 |
+
### Training results
|
48 |
+
|
49 |
+
| Training Loss | Epoch | Step | Validation Loss |
|
50 |
+
|:-------------:|:-----:|:----:|:---------------:|
|
51 |
+
| 1638296.8344 | 1.0 | 326 | 1449155.375 |
|
52 |
+
| 1164437.5951 | 2.0 | 652 | 871450.75 |
|
53 |
+
| 659014.773 | 3.0 | 978 | 472353.125 |
|
54 |
+
| 345279.4356 | 4.0 | 1304 | 236237.5781 |
|
55 |
+
| 165353.8528 | 5.0 | 1630 | 106501.5078 |
|
56 |
+
| 70656.4785 | 6.0 | 1956 | 42171.0586 |
|
57 |
+
| 26332.638 | 7.0 | 2282 | 14457.2051 |
|
58 |
+
| 8663.8098 | 8.0 | 2608 | 4628.3350 |
|
59 |
+
| 2883.4448 | 9.0 | 2934 | 1723.0411 |
|
60 |
+
| 1233.9951 | 10.0 | 3260 | 900.9794 |
|
61 |
+
| 746.439 | 11.0 | 3586 | 638.7797 |
|
62 |
+
| 582.4893 | 12.0 | 3912 | 545.1293 |
|
63 |
+
| 518.9121 | 13.0 | 4238 | 505.4234 |
|
64 |
+
| 491.481 | 14.0 | 4564 | 487.2142 |
|
65 |
+
| 478.4722 | 15.0 | 4890 | 478.1264 |
|
66 |
+
| 471.7958 | 16.0 | 5216 | 473.6396 |
|
67 |
+
| 467.9093 | 17.0 | 5542 | 470.8682 |
|
68 |
+
| 465.5827 | 18.0 | 5868 | 469.4048 |
|
69 |
+
| 463.9871 | 19.0 | 6194 | 468.4793 |
|
70 |
+
| 462.7912 | 20.0 | 6520 | 467.4167 |
|
71 |
+
| 461.7637 | 21.0 | 6846 | 466.8257 |
|
72 |
+
| 460.9475 | 22.0 | 7172 | 465.8925 |
|
73 |
+
| 460.0868 | 23.0 | 7498 | 465.6684 |
|
74 |
+
| 459.2581 | 24.0 | 7824 | 465.3550 |
|
75 |
+
| 458.514 | 25.0 | 8150 | 464.5980 |
|
76 |
+
| 457.7133 | 26.0 | 8476 | 464.2821 |
|
77 |
+
| 456.9633 | 27.0 | 8802 | 464.1039 |
|
78 |
+
| 456.1794 | 28.0 | 9128 | 463.6459 |
|
79 |
+
| 455.3521 | 29.0 | 9454 | 463.4857 |
|
80 |
+
| 454.5061 | 30.0 | 9780 | 463.4343 |
|
81 |
+
|
82 |
+
|
83 |
+
### Framework versions
|
84 |
+
|
85 |
+
- Transformers 4.44.2
|
86 |
+
- Pytorch 2.4.0+cu124
|
87 |
+
- Datasets 2.21.0
|
88 |
+
- Tokenizers 0.19.1
|
del_model/config.json
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
{
|
2 |
-
"_name_or_path": "/home/ljw/sdc1/CRISPR_results/Lindel/SX_ispymac_Lindel_del",
|
3 |
"architectures": [
|
4 |
"LindelModel"
|
5 |
],
|
|
|
1 |
{
|
|
|
2 |
"architectures": [
|
3 |
"LindelModel"
|
4 |
],
|
del_model/model.py
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import PretrainedConfig, PreTrainedModel
|
2 |
+
import torch.nn as nn
|
3 |
+
import torch
|
4 |
+
import torch.nn.functional as F
|
5 |
+
|
6 |
+
class LindelConfig(PretrainedConfig):
|
7 |
+
model_type = "Lindel"
|
8 |
+
label_names = ["count"]
|
9 |
+
|
10 |
+
def __init__(
|
11 |
+
self,
|
12 |
+
dlen = 30, # the upper limit of deletion length (strictly less than dlen)
|
13 |
+
mh_len = 4, # the upper limit of micro-homology length
|
14 |
+
model = "indel", # the actual model, should be "indel", "del", or "ins"
|
15 |
+
reg_mode = "l2", # regularization method, should be "l2" or "l1"
|
16 |
+
reg_const = 0.01, # regularization coefficient
|
17 |
+
seed = 63036, # random seed for intialization
|
18 |
+
**kwargs,
|
19 |
+
):
|
20 |
+
self.dlen = dlen
|
21 |
+
self.mh_len = mh_len
|
22 |
+
self.model = model
|
23 |
+
self.reg_mode = reg_mode
|
24 |
+
self.reg_const = reg_const
|
25 |
+
self.seed = seed
|
26 |
+
super().__init__(**kwargs)
|
27 |
+
|
28 |
+
class LindelModel(PreTrainedModel):
|
29 |
+
config_class = LindelConfig
|
30 |
+
|
31 |
+
def __init__(self, config) -> None:
|
32 |
+
super().__init__(config)
|
33 |
+
# In more recent versions of PyTorch, you no longer need to explicitly register_parameter, it's enough to set a member of your nn.Module with nn.Parameter to "notify" pytorch that this variable should be treated as a trainable parameter (https://stackoverflow.com/questions/59234238/how-to-add-parameters-in-module-class-in-pytorch-custom-model).
|
34 |
+
self.generator = torch.Generator().manual_seed(config.seed)
|
35 |
+
self.reg_mode = config.reg_mode
|
36 |
+
self.reg_const = config.reg_const
|
37 |
+
if config.model == "indel":
|
38 |
+
# onehotencoder(ref[cut-17:cut+3])
|
39 |
+
feature_dim = 20 * 4 + 19 * 16
|
40 |
+
class_dim = 2
|
41 |
+
elif config.model == "ins":
|
42 |
+
# onehotencoder(ref[cut-3:cut+3])
|
43 |
+
feature_dim = 6 * 4 + 5 * 16
|
44 |
+
class_dim = 21
|
45 |
+
elif config.model == "del":
|
46 |
+
class_dim = (4 + 1 + 4 + config.dlen - 1) * (config.dlen - 1) // 2
|
47 |
+
# concatenate get_feature and onehotencoder(ref[cut-17:cut+3])
|
48 |
+
feature_dim = class_dim * (config.mh_len + 1) + 20 * 4 + 19 * 16
|
49 |
+
self.linear = nn.Linear(in_features=feature_dim, out_features=class_dim)
|
50 |
+
self.initialize_weights()
|
51 |
+
|
52 |
+
def initialize_weights(self):
|
53 |
+
for m in self.modules():
|
54 |
+
if isinstance(m, nn.Linear):
|
55 |
+
nn.init.normal_(m.weight, mean=0, std=1, generator=self.generator)
|
56 |
+
if m.bias is not None:
|
57 |
+
nn.init.constant_(m.bias, 0)
|
58 |
+
|
59 |
+
def forward(self, input, count=None) -> torch.Tensor:
|
60 |
+
logit = self.linear(input)
|
61 |
+
if count is not None:
|
62 |
+
return {
|
63 |
+
"logit": logit,
|
64 |
+
"loss": self.cross_entropy_reg(logit, count)
|
65 |
+
}
|
66 |
+
return {"logit": logit}
|
67 |
+
|
68 |
+
def cross_entropy_reg(self, logit, count):
|
69 |
+
if self.reg_mode == "l2":
|
70 |
+
reg_term = (self.linear.weight ** 2).sum()
|
71 |
+
elif self.reg_mode == "l1":
|
72 |
+
reg_term = abs(self.linear.weight).sum()
|
73 |
+
return -(F.log_softmax(logit, dim=1) * F.normalize(count.to(torch.float32), p=1.0, dim=1)).sum() + logit.shape[0] * self.reg_const * reg_term
|
del_model/runs/Nov20_11-56-17_ljw-System-Product-Name/events.out.tfevents.1732076861.ljw-System-Product-Name.1244212.2
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:267073baf0ab3654eb653ae0648b751d92762e5c9b8db3b68dec2ae3be35cc1f
|
3 |
+
size 19402
|
del_model/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f4cd672b6bea1c4f65e4fd1eceb6ac99713999f19259ba468c7b15d2398a7d06
|
3 |
+
size 5304
|