ljw20180420 commited on
Commit
47a01cb
·
verified ·
1 Parent(s): 44bb39d

Upload folder using huggingface_hub

Browse files
CRISPR_transformer_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_CRISPR_transformer
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_CRISPR_transformer
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: 514639.75
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
+ | 5601914.5031 | 1.0 | 326 | 1894021.75 |
52
+ | 1328778.8957 | 2.0 | 652 | 670578.75 |
53
+ | 669992.0982 | 3.0 | 978 | 528672.8125 |
54
+ | 549468.5644 | 4.0 | 1304 | 528315.75 |
55
+ | 528034.8957 | 5.0 | 1630 | 517330.3438 |
56
+ | 521024.6871 | 6.0 | 1956 | 516302.25 |
57
+ | 518358.3804 | 7.0 | 2282 | 516195.9375 |
58
+ | 517674.454 | 8.0 | 2608 | 516099.6875 |
59
+ | 516467.3865 | 9.0 | 2934 | 515717.6562 |
60
+ | 516283.1411 | 10.0 | 3260 | 516509.0 |
61
+ | 515811.4356 | 11.0 | 3586 | 515362.1875 |
62
+ | 515361.1779 | 12.0 | 3912 | 517239.9375 |
63
+ | 515421.5951 | 13.0 | 4238 | 515716.4688 |
64
+ | 515266.2577 | 14.0 | 4564 | 514972.875 |
65
+ | 514957.9877 | 15.0 | 4890 | 514995.125 |
66
+ | 514826.3558 | 16.0 | 5216 | 515276.4688 |
67
+ | 514742.8221 | 17.0 | 5542 | 514949.9375 |
68
+ | 514670.9693 | 18.0 | 5868 | 515125.5 |
69
+ | 514493.3988 | 19.0 | 6194 | 514852.7812 |
70
+ | 514367.3129 | 20.0 | 6520 | 514896.3125 |
71
+ | 514363.1411 | 21.0 | 6846 | 515543.625 |
72
+ | 514226.3067 | 22.0 | 7172 | 514779.0 |
73
+ | 514206.135 | 23.0 | 7498 | 514666.75 |
74
+ | 514089.4233 | 24.0 | 7824 | 514983.75 |
75
+ | 514020.908 | 25.0 | 8150 | 514966.5625 |
76
+ | 513915.8282 | 26.0 | 8476 | 514978.0938 |
77
+ | 513902.9202 | 27.0 | 8802 | 514722.125 |
78
+ | 513746.454 | 28.0 | 9128 | 514688.625 |
79
+ | 513719.0675 | 29.0 | 9454 | 514638.1562 |
80
+ | 513652.319 | 30.0 | 9780 | 514639.75 |
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
CRISPR_transformer_model/config.json CHANGED
@@ -1,5 +1,4 @@
1
  {
2
- "_name_or_path": "/home/ljw/sdc1/CRISPR_results/CRISPR_transformer/SX_ispymac_CRISPR_transformer",
3
  "architectures": [
4
  "CRISPRTransformerModel"
5
  ],
 
1
  {
 
2
  "architectures": [
3
  "CRISPRTransformerModel"
4
  ],
CRISPR_transformer_model/model.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import PreTrainedModel, RoFormerConfig, RoFormerModel
2
+ import torch.nn as nn
3
+ import torch
4
+ import torch.nn.functional as F
5
+ import numpy as np
6
+
7
+ class CRISPRTransformerConfig(RoFormerConfig):
8
+ model_type = "CRISPR_transformer"
9
+ label_names = ["observation"]
10
+
11
+ def __init__(
12
+ self,
13
+ vocab_size = 4, # ACGT
14
+ hidden_size = 256, # model embedding dimension
15
+ num_hidden_layers = 3, # number of EncoderLayer
16
+ num_attention_heads = 4, # number of attention heads
17
+ intermediate_size = 1024, # FeedForward intermediate dimension size
18
+ hidden_dropout_prob = 0.1, # The dropout probability for all fully connected layers in the embeddings, encoder, and pooler
19
+ attention_probs_dropout_prob = 0.1, # The dropout ratio for the attention probabilities
20
+ max_position_embeddings = 256, # The maximum sequence length that this model might ever be used with. Typically set this to something large just in case (e.g., 512 or 1024 or 1536).
21
+ ref1len = 127, # length of reference 1
22
+ ref2len = 127, # length of reference 2
23
+ seed = 63036, # random seed for intialization
24
+ **kwargs
25
+ ):
26
+ self.ref1len = ref1len
27
+ self.ref2len = ref2len
28
+ self.seed = seed
29
+ super().__init__(
30
+ vocab_size = vocab_size,
31
+ hidden_size = hidden_size,
32
+ num_hidden_layers = num_hidden_layers,
33
+ num_attention_heads = num_attention_heads,
34
+ intermediate_size = intermediate_size,
35
+ hidden_dropout_prob = hidden_dropout_prob,
36
+ attention_probs_dropout_prob = attention_probs_dropout_prob,
37
+ max_position_embeddings = max_position_embeddings,
38
+ **kwargs
39
+ )
40
+
41
+ class CRISPRTransformerModel(PreTrainedModel):
42
+ config_class = CRISPRTransformerConfig
43
+
44
+ def __init__(self, config):
45
+ super().__init__(config)
46
+ self.generator = torch.Generator().manual_seed(config.seed)
47
+ self.model = RoFormerModel(config)
48
+ self.mlp = nn.Linear(
49
+ in_features=config.hidden_size,
50
+ out_features=(config.ref1len + 1) * (config.ref2len + 1)
51
+ )
52
+ self.initialize_weights()
53
+
54
+ def initialize_weights(self):
55
+ for m in self.modules():
56
+ if isinstance(m, nn.Linear):
57
+ nn.init.normal_(m.weight, mean=0, std=1, generator=self.generator)
58
+ if m.bias is not None:
59
+ nn.init.constant_(m.bias, 0)
60
+
61
+ def forward(self, refcode: torch.Tensor, observation: torch.Tensor=None):
62
+ # refcode (batch_size X sequence_length)
63
+ # model(refcode) (batch_size X sequence_length X hidden_size)
64
+ # model(refcode)[:, -1, :] arbitrary choose the last position to predict the logits
65
+ batch_size = refcode.shape[0]
66
+ logit = self.mlp(
67
+ self.model(
68
+ input_ids=refcode,
69
+ attention_mask=torch.ones(
70
+ batch_size,
71
+ self.config.ref1len + self.config.ref2len,
72
+ dtype=torch.int64,
73
+ device=self.model.device
74
+ )
75
+ ).last_hidden_state[:, -1, :]
76
+ ).view(batch_size, self.config.ref2len + 1, self.config.ref1len + 1)
77
+ if observation is not None:
78
+ return {
79
+ "logit": logit,
80
+ "loss": - (
81
+ observation.flatten(start_dim=1) *
82
+ F.log_softmax(logit.flatten(start_dim=1), dim=1)
83
+ ).sum()
84
+ }
85
+ return {"logit": logit}
CRISPR_transformer_model/runs/Nov18_13-19-23_ljw-System-Product-Name/events.out.tfevents.1731907165.ljw-System-Product-Name.35960.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fcaba17bb30e7ec94f7abe72eb17745d1bede8b4937023a5812a31f5e26c42d4
3
+ size 19851
CRISPR_transformer_model/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:74fb56f007b2e91b3fac96d9bc9f26ea19800479595e6b2d6891946b34402dc9
3
+ size 5304