| # CCFM (Cascaded Conditioned Flow Matching) ๆถๆๆๆกฃ |
|
|
| ## ไธใ้กน็ฎๆฆ่ฟฐ |
|
|
| CCFM ๆฏไธไธช**็บง่ๆตๅน้
**ๆกๆถ๏ผ่ๅไธไธชๆจกๅ็ไผๅฟๆฅๅๅ็ป่ๆฐๅจ้ขๆต๏ผ |
|
|
| - **scDFM**๏ผๅบ็กๆตๅน้
ๆถๆ๏ผbackboneใๆฐๆฎๅ ่ฝฝใ่ฎญ็ป่ๅผ๏ผ |
| - **LatentForcing**๏ผ็บง่ๅๆตๆๆณ๏ผlatent ๆต + ่กจ่พพๆตๅ้ถๆฎต็ๆ๏ผ |
| - **scGPT**๏ผๅป็ป็้ข่ฎญ็ปๆจกๅ๏ผๆไพ per-gene ไธไธๆๅ็นๅพ |
|
|
| ### ๆ ธๅฟๅๆฐ |
|
|
| ๅ้ด LatentForcing ็ๅๆตๆถๆ๏ผๅฐๅ
ถไปๅพๅๅ่ฟ็งปๅฐๅ็ป่ๅ๏ผ |
|
|
| | LatentForcing (ๅพๅ) | CCFM (ๅ็ป่) | |
| |---|---| |
| | ๅ็ด ๅผ | ๅบๅ ่กจ่พพๅผ | |
| | DINO-v2 ็นๅพ๏ผ่พ
ๅฉ็ๆ็ฎๆ ๏ผ | scGPT ไธไธๆ็นๅพ๏ผ่พ
ๅฉ็ๆ็ฎๆ ๏ผ | |
| | ็ฑปๅซๆ ็ญพ๏ผๆกไปถไฟกๅท๏ผ | control ่กจ่พพ + perturbation_id๏ผๆกไปถไฟกๅท๏ผ | |
| |
| **ๅ
ณ้ฎๅบๅ**๏ผscGPT ็นๅพๆฏไป target๏ผๆฐๅจ็ป่๏ผๆๅ็**่พ
ๅฉ็ๆ็ฎๆ **๏ผไธๆฏๆกไปถไฟกๅทใๆจ็ๆถๆจกๅไปๅชๅฃฐ็ๆ scGPT ็นๅพ๏ผStage 1๏ผ๏ผๅ็จ็ๆ็็นๅพๅผๅฏผ่กจ่พพๅผ็ๆ๏ผStage 2๏ผใ็ๆญฃ็ๆกไปถไฟกๅทๆฏ control ่กจ่พพๅ perturbation_id๏ผๅฎไปฌๅจๆจ็ๆถๅง็ปๅฏ่ทๅใ |
|
|
| ### ๆไปถ็ปๆ |
|
|
| ``` |
| CCFM/ |
| โโโ _bootstrap_scdfm.py # Bootstrap scDFM ๆจกๅ๏ผๅฝๅ็ฉบ้ด้็ฆป |
| โโโ config/ |
| โ โโโ config_cascaded.py # CascadedFlowConfig dataclass (tyro CLI) |
| โโโ src/ |
| โ โโโ __init__.py |
| โ โโโ utils.py # Re-exports scDFM utils |
| โ โโโ _scdfm_imports.py # scDFM ๆจกๅ้ไธญๅฏผๅ
ฅ |
| โ โโโ denoiser.py # CascadedDenoiser (่ฎญ็ป/ๆจ็้ป่พ) |
| โ โโโ model/ |
| โ โ โโโ model.py # CascadedFlowModel ๅๆตๆจกๅ |
| โ โ โโโ layers.py # LatentEmbedder, LatentDecoder |
| โ โโโ data/ |
| โ โโโ data.py # scDFM ๆฐๆฎๅ ่ฝฝ้ๆ |
| โ โโโ scgpt_extractor.py # FrozenScGPTExtractor |
| โโโ scripts/ |
| โ โโโ run_cascaded.py # ่ฎญ็ป/่ฏไผฐๅ
ฅๅฃ |
| โ โโโ download_scgpt.py # ไธ่ฝฝ scGPT ้ข่ฎญ็ปๆจกๅ |
| โโโ run.sh # pjsub ๆจกๆฟ |
| โโโ run_topk30_neg.sh # ๅฎๆดๅๆฐๅ job ่ๆฌ |
| ``` |
|
|
| ### ้ป่ฎค่ถ
ๅๆฐ |
|
|
| | ๅๆฐ | ๅผ | ่ฏดๆ | |
| |---|---|---| |
| | `B` | 48 | batch size | |
| | `G_full` | 5000 | HVG ๆปๆฐ | |
| | `G` | 1000 | ่ฎญ็ปๆถ้ๆบๅบๅ ๅญ้ | |
| | `d_model` | 128 | ้่็ปดๅบฆ | |
| | `scgpt_dim` | 512 | scGPT ่พๅบ็นๅพ็ปดๅบฆ | |
| | `bottleneck_dim` | 128 | LatentEmbedder ็ถ้ข็ปดๅบฆ | |
| | `nhead` | 8 | ๆณจๆๅๅคดๆฐ | |
| | `nlayers` | 4 | Transformer ๅฑๆฐ | |
| | `dh_depth` | 2 | LatentDecoder block ๆฐ | |
| | `choose_latent_p` | 0.4 | ่ฎญ็ป latent ๆต็ๆฆ็ | |
| | `latent_weight` | 1.0 | latent loss ๆ้ | |
| | `gamma` | 0.5 | MMD loss ๆ้ | |
| | `lr` | 5e-5 | ๅญฆไน ็ | |
| | `steps` | 200000 | ่ฎญ็ปๆปๆญฅๆฐ | |
| | `latent_steps` | 20 | ๆจ็ ODE ๆญฅๆฐ๏ผlatent๏ผ | |
| | `expr_steps` | 20 | ๆจ็ ODE ๆญฅๆฐ๏ผ่กจ่พพ๏ผ | |
| | `warmup_batches` | 200 | scGPT running stats ้ข็ญ | |
|
|
| --- |
|
|
| ## ไบใ่ฎญ็ปๆต็จ Tensor ๆฐๆฎๆต |
|
|
| ### 2.1 ๆฐๆฎๅๅค |
|
|
| ``` |
| ่พๅ
ฅ: |
| source: (B, G_full=5000) ๆงๅถ็ป่กจ่พพ |
| target: (B, G_full=5000) ๆฐๅจๅ่กจ่พพ |
| perturbation_id: (B, 2) ๆฐๅจ token ID |
| gene_ids: (G_full=5000,) ๅ
จ้จๅบๅ ็ vocab ID |
| |
| ้ๆบ้ๆ ท 1000 ไธชๅบๅ : |
| input_gene_ids = randperm(5000)[:1000] โ (1000,) |
| source_sub = source[:, input_gene_ids] โ (48, 1000) |
| target_sub = target[:, input_gene_ids] โ (48, 1000) |
| gene_input = gene_ids[input_gene_ids].expand โ (48, 1000) |
| ``` |
|
|
| ### 2.2 ๅป็ป scGPT ๆๅ่พ
ๅฉ็ๆ็ฎๆ ๏ผ็ฑปไผผ LatentForcing ็ DINO ็นๅพๆๅ๏ผ |
|
|
| ``` |
| scgpt_extractor.extract(target_sub, gene_indices=input_gene_ids): |
| |
| target_sub: (48, 1000) ่พๅ
ฅ่กจ่พพ |
| hvg_ids: (1000,) HVG โ scGPT vocab ID ๆ ๅฐ |
| valid_mask: (1000,) bool, ่ฟๆปคๅจ scGPT vocab ไธญ็ๅบๅ |
| expr_valid: (48, G_valid) ๆๆๅบๅ ็่กจ่พพๅผ |
| |
| ่ฅ G_valid+1 > max_seq_len(1200): |
| ้ๆบ้ๆ ท 1199 ไธชๅบๅ |
| seq_len = 1200 |
| ๅฆๅ: |
| seq_len = G_valid + 1 |
| |
| ๆผๆฅ CLS token: |
| src = [cls_id | gene_ids] โ (48, seq_len) long |
| values = [0 | expr_valid] โ (48, seq_len) float |
| |
| scGPT frozen forward: |
| encoder_out = scgpt._encode(src, values, mask) โ (48, seq_len, 512) |
| |
| ๅปๆ CLS, scatter ๅๅบๅฎไฝ็ฝฎ: |
| gene_features = encoder_out[:, 1:, :] โ (48, seq_len-1, 512) |
| output = zeros(48, 1000, 512) |
| output.scatter_(1, idx, gene_features) โ (48, 1000, 512) |
| |
| ๅฝไธๅ (running mean/var, warmup 200 batches ๅๅป็ป): |
| output = (output - running_mean) / sqrt(running_var) * target_std |
| |
| z_target: (48, 1000, 512) |
| ``` |
|
|
| ### 2.3 ็บง่ๆถ้ด้ๆ ท |
|
|
| ``` |
| t_latent = rand(48) โ (48,) |
| t_expr = rand(48) โ (48,) |
| choose_latent_mask = rand(48) < 0.4 โ (48,) bool |
| |
| ๅฏนๆฏไธชๆ ทๆฌไบ้ไธ: |
| ่ฅ mask=True (40%ๆฆ็): t_latent ไฟ็, t_expr=0, w_expr=0, w_latent=1 โ ่ฎญ็ป latent ๆต |
| ่ฅ mask=False (60%ๆฆ็): t_expr ไฟ็, t_latent=1, w_expr=1, w_latent=0 โ ่ฎญ็ป่กจ่พพๆต |
| |
| ่พๅบ: |
| t_expr: (48,) ่กจ่พพๆตๆถ้ดๆญฅ |
| t_latent: (48,) ๆฝๅ้ๆตๆถ้ดๆญฅ |
| w_expr: (48,) ่กจ่พพ loss ๆ้ (0 ๆ 1) |
| w_latent: (48,) ๆฝๅ้ loss ๆ้ (0 ๆ 1) |
| ``` |
|
|
| ### 2.4 Flow Path ้ๆ ท๏ผ็บฟๆงๆๅผ + ้ๅบฆ๏ผ |
|
|
| ``` |
| ่กจ่พพๆต: |
| noise_expr = randn_like(source_sub) โ (48, 1000) |
| path_expr = AffineProbPath.sample(t_expr, noise_expr, target_sub) |
| path_expr.x_t = (1-t)*noise + t*target โ (48, 1000) ๆๅผๅ็ๅชๅฃฐ่กจ่พพ |
| path_expr.dx_t = target - noise โ (48, 1000) ็ฎๆ ้ๅบฆ (ground truth) |
| |
| ๆฝๅ้ๆต: |
| noise_latent = randn_like(z_target) โ (48, 1000, 512) |
| ๅฑๅนณ: |
| z_target_flat = z_target.reshape(48, 512000) โ (48, 512000) |
| noise_latent_flat = noise_latent.reshape(48, 512000) โ (48, 512000) |
| path_latent_flat = AffineProbPath.sample(t_latent, noise_latent_flat, z_target_flat) |
| ่ฟๅ: |
| path_latent.x_t = reshape โ (48, 1000, 512) ๆๅผๅ็ๅชๅฃฐ latent |
| path_latent.dx_t = reshape โ (48, 1000, 512) ็ฎๆ ้ๅบฆ |
| ``` |
|
|
| ### 2.5 ๆจกๅๅๅไผ ๆญ (`CascadedFlowModel.forward`) |
|
|
| ``` |
| ่พๅ
ฅ: |
| gene_input: (48, 1000) ๅบๅ token ID |
| source_sub: (48, 1000) ๆบ่กจ่พพ |
| path_expr.x_t: (48, 1000) ๅชๅฃฐ่กจ่พพ |
| path_latent.x_t: (48, 1000, 512) ๅชๅฃฐ latent |
| t_expr: (48,) |
| t_latent: (48,) |
| perturbation_id: (48, 2) |
| ``` |
|
|
| #### Step 5a: ่กจ่พพๆต Embedding |
|
|
| ``` |
| gene_emb = GeneEncoder(gene_input) โ (48, 1000, 128) |
| val_emb_1 = ContinuousValueEncoder(x_t) โ (48, 1000, 128) encoder_1 = ๅชๅฃฐ target (ๅ scDFM) |
| val_emb_2 = ContinuousValueEncoder(source_sub) โ (48, 1000, 128) encoder_2 = control (ๅ scDFM) |
| expr_tokens = fusion_layer(cat[val_emb_1, val_emb_2]) + gene_emb |
| = Linear(256โ128) โ GELU โ Linear(128โ128) โ LN + gene_emb โ (48, 1000, 128) |
| ``` |
|
|
| > **่ฎพ่ฎก่ฏดๆ**๏ผไธ scDFM ๅฏน้ฝ๏ผ๏ผ |
| > - `value_encoder_1` ็ผ็ ๅชๅฃฐ target๏ผ`x_t`๏ผ๏ผ`value_encoder_2` ็ผ็ control๏ผ`source`๏ผ๏ผไธ scDFM ่ง่ฒไธ่ด |
| > - `gene_emb` ๅชๅจ่ๅๅๅ ไธๆฌก๏ผๅปๅไฝ๏ผ๏ผ่้ๅๅซๅ ๅฐไธคไธช encoder ็่พๅบไธ |
| > - `val_emb_2`๏ผcontrol ๅตๅ
ฅ๏ผไผ ๅ
ฅ backbone ็ DiffPerceiverBlock ไฝไธบไบคๅๆณจๆๅ KV๏ผ็จณๅฎๅ่ๅบ็บฟ๏ผ |
|
|
| #### Step 5b: ๆฝๅ้ๆต Embedding |
|
|
| ``` |
| latent_tokens = LatentEmbedder(path_latent.x_t) |
| = Linear(512โ128) โ GELU โ Linear(128โ128) โ (48, 1000, 128) |
| ``` |
|
|
| #### Step 5c: ๅๆต่ๅ |
|
|
| ``` |
| x = expr_tokens + latent_tokens โ (48, 1000, 128) |
| ``` |
|
|
| #### Step 5d: ๆกไปถๅ้ |
|
|
| ``` |
| t_expr_emb = TimestepEmbedder(t_expr) โ (48, 128) |
| t_latent_emb = TimestepEmbedder(t_latent) โ (48, 128) |
| pert_emb = GeneEncoder(perturbation_id).mean(dim=1) โ (48, 128) |
| # perturbation_id: (48,2) โ encoder โ (48,2,128) โ mean โ (48,128) |
| c = t_expr_emb + t_latent_emb + pert_emb โ (48, 128) |
| ``` |
|
|
| #### Step 5e: ๅ
ฑไบซ Backbone (4 ๅฑ DiffPerceiverBlock) |
|
|
| ``` |
| for i in range(4): |
| # GeneadaLN: ็จ gene_emb ่ฐๅถ x |
| x = gene_adaLN[i](gene_emb, x) โ (48, 1000, 128) |
| |
| # Adapter: ๆผๆฅ pert_emb ๅ้็ปด |
| pert_exp = pert_emb[:, None, :].expand(-1, 1000, -1) โ (48, 1000, 128) |
| x = cat[x, pert_exp] โ (48, 1000, 256) |
| x = adapter_layer[i](x) |
| = Linear(256โ128) โ LeakyReLU โ Linear(128โ128) โ LeakyReLU |
| โ (48, 1000, 128) |
| |
| # DiffPerceiverBlock: attention + MLP, ็จ c ๅ AdaLN ๆกไปถ |
| x = DiffPerceiverBlock(x, val_emb_2, c) โ (48, 1000, 128) |
| ``` |
|
|
| #### Step 5f: ่กจ่พพ Decoder Head |
|
|
| ``` |
| x_with_pert = cat[x, pert_exp] โ (48, 1000, 256) |
| pred_v_expr = ExprDecoder(x_with_pert)["pred"] โ (48, 1000) |
| ``` |
|
|
| #### Step 5g: Latent Decoder Head |
|
|
| ``` |
| h = dh_proj(x) # Linear(128โ128) โ (48, 1000, 128) |
| |
| for j in range(2): # dh_depth=2 |
| # AdaLN: c โ SiLU โ Linear(128โ768) โ chunk 6 |
| shift_msa, scale_msa, gate_msa, |
| shift_mlp, scale_mlp, gate_mlp = adaLN_modulation(c) ๅ (48, 128) |
| |
| # Self-Attention with AdaLN |
| h_norm = LayerNorm(h) * (1+scale_msa[:,None,:]) + shift_msa[:,None,:] |
| โ (48, 1000, 128) |
| h_attn = MultiheadAttention(h_norm, h_norm, h_norm) โ (48, 1000, 128) |
| h = h + gate_msa[:,None,:] * h_attn โ (48, 1000, 128) |
| |
| # MLP with AdaLN |
| h_norm = LayerNorm(h) * (1+scale_mlp[:,None,:]) + shift_mlp[:,None,:] |
| โ (48, 1000, 128) |
| h_mlp = Linear(128โ512) โ GELU โ Linear(512โ128) โ (48, 1000, 128) |
| h = h + gate_mlp[:,None,:] * h_mlp โ (48, 1000, 128) |
| |
| pred_v_latent = final(h) |
| = LN โ Linear(128โ128) โ GELU โ Linear(128โ512) โ (48, 1000, 512) |
| ``` |
|
|
| ### 2.6 Loss ่ฎก็ฎ |
|
|
| ``` |
| loss_expr = MSE(pred_v_expr - path_expr.dx_t) * w_expr[:, None] |
| = ((48,1000) - (48,1000))^2 * (48,1) โ mean โ scalar |
| ๅชๅฏน w_expr=1 ็ๆ ทๆฌๆ่ดก็ฎ (็บฆ60%) |
| |
| loss_latent = MSE(pred_v_latent - path_latent.dx_t) * w_latent[:, None, None] |
| = ((48,1000,512) - (48,1000,512))^2 * (48,1,1) โ mean โ scalar |
| ๅชๅฏน w_latent=1 ็ๆ ทๆฌๆ่ดก็ฎ (็บฆ40%) |
| |
| loss = loss_expr + latent_weight * loss_latent |
| |
| ๅฏ้ MMD loss (ๅฏน w_expr>0 ็ๆ ทๆฌ): |
| x1_hat = x_t + pred_v_expr * (1-t_expr) # ๅๆญฅ้ๅปบ โ (N_expr, 1000) |
| mmd_loss = mmd2_unbiased_multi_sigma(x1_hat, target_sub) โ scalar |
| loss += gamma * mmd_loss |
| ``` |
|
|
| ### 2.7 ่ฎญ็ปๅพช็ฏ |
|
|
| ``` |
| for iteration in range(200000): |
| batch โ source(48, 5000), target(48, 5000), pert_id(48, 2) |
| loss = denoiser.train_step(source, target, pert_id, gene_ids, infer_top_gene=1000) |
| optimizer.zero_grad() |
| accelerator.backward(loss) |
| optimizer.step() |
| scheduler.step() # CosineAnnealing |
| |
| if iteration % 5000 == 0: |
| save checkpoint + run evaluation |
| ``` |
|
|
| --- |
|
|
| ## ไธใๆจ็ๆต็จ Tensor ๆฐๆฎๆต |
|
|
| ๆจ็ๆถ**ไธ่ฐ็จ scGPT ็ผ็ ๅจ**๏ผๆจกๅไปๅชๅฃฐ่ช่ก็ๆ latent๏ผ่พ
ๅฉ่ฏญไน่กจๅพ๏ผใ็จ**ๅ
จ้จ 5000 ไธชๅบๅ **๏ผไธๅๅญ้้ๆ ทใ |
| ๆกไปถไฟกๅท๏ผcontrol ่กจ่พพ + perturbation_id๏ผๅจๆฏไธช ODE ๆญฅไธญๆ็ปญๆไพใ |
| |
| ``` |
| ่พๅ
ฅ: |
| source: (B, 5000) ๆงๅถ็ป่กจ่พพ |
| perturbation_id: (B, 2) ๆฐๅจ ID |
| gene_ids: (B, 5000) ๅบๅ vocab ID |
| ``` |
| |
| ### 3.1 Stage 1: ็ๆ Latent๏ผt_latent: 0โ1, t_expr ๅบๅฎ=0๏ผ |
| |
| ``` |
| z_noise = randn(B, 5000, 512) ๅๅงๅชๅฃฐ |
|
|
| ODE ๆฑ่งฃ (RK4, 20ๆญฅ, t โ [0,1]): |
| ๆฏไธๆญฅ่ฐ็จ latent_vf(t, z_t): |
| t_latent = t.expand(B) โ (B,) ๅฝๅๆถ้ดๆญฅ |
| t_expr = zeros(B) โ (B,) ๅบๅฎไธบ 0 |
| |
| model.forward( |
| gene_ids, (B, 5000) |
| source, (B, 5000) ๆบ่กจ่พพ |
| source, (B, 5000) โ ๆณจๆ: x_t ็จ source (ๅ ไธบ t_expr=0) |
| z_t, (B, 5000, 512) ๅฝๅ latent ็ถๆ |
| t_expr=0, (B,) |
| t_latent=t, (B,) |
| perturbation_id, (B, 2) |
| ) |
| โ _, v_latent (B, 5000, 512) latent ้ๅบฆๅบ |
| |
| return v_latent |
| |
| z_traj = odeint(latent_vf, z_noise, linspace(0,1,20)) |
| โ (20, B, 5000, 512) |
| z_generated = z_traj[-1] โ (B, 5000, 512) โ
็ๆ็ latent |
| ``` |
| |
| ### 3.2 Stage 2: ็จ็ๆ็ Latent ๅผๅฏผ่กจ่พพ็ๆ๏ผt_expr: 0โ1, t_latent ๅบๅฎ=1๏ผ |
| |
| ``` |
| expr_noise = randn_like(source) โ (B, 5000) ้ซๆฏๅชๅฃฐ (ๆ Poisson) |
| |
| ODE ๆฑ่งฃ (RK4, 20ๆญฅ, t โ [0,1]): |
| ๆฏไธๆญฅ่ฐ็จ expr_vf(t, x_t): |
| t_expr = t.expand(B) โ (B,) ๅฝๅๆถ้ดๆญฅ |
| t_latent = ones(B) โ (B,) ๅบๅฎไธบ 1 (latent ๅทฒๅฎๆ) |
| |
| model.forward( |
| gene_ids, (B, 5000) |
| source, (B, 5000) |
| x_t, (B, 5000) โ ๅฝๅๅชๅฃฐ่กจ่พพ |
| z_generated, (B, 5000, 512) โ
Stage 1 ็็ปๆ (ๅบๅฎ) |
| t_expr=t, (B,) |
| t_latent=1, (B,) |
| perturbation_id, (B, 2) |
| ) |
| โ v_expr, _ (B, 5000) ่กจ่พพ้ๅบฆๅบ |
| |
| return v_expr |
| |
| x_traj = odeint(expr_vf, expr_noise, linspace(0,1,20)) |
| โ (20, B, 5000) |
| x_generated = clamp(x_traj[-1], min=0) โ (B, 5000) โ
ๆ็ป้ขๆต่กจ่พพ |
| ``` |
| |
| ### 3.3 ่ฏไผฐๆต็จ |
| |
| ``` |
| ๅฏนๆฏไธชๆฐๅจๆกไปถ: |
| source = ้ๆบ้ๆ ท 128 ไธชๆงๅถ็ป่ โ (128, 5000) |
| ๆ batch_size ่ฐ็จ generate: |
| pred = denoiser.generate(source, pert_id, gene_ids) โ (128, 5000) |
| |
| ๆฑๆป: |
| pred_adata = AnnData(X=ๆๆ้ขๆต่กจ่พพ, obs=ๆฐๅจๆ ็ญพ) |
| real_adata = AnnData(X=ๆๆ็ๅฎ่กจ่พพ, obs=ๆฐๅจๆ ็ญพ) |
| MetricsEvaluator(pred_adata, real_adata) โ results.csv, agg_results.csv |
| ``` |
| |
| --- |
| |
| ## ๅใ่ฎญ็ป vs ๆจ็ ๅฏนๆฏๆป็ป |
| |
| | ็ปดๅบฆ | ่ฎญ็ป | ๆจ็ | |
| |---|---|---| |
| | ๅบๅ ๆฐ | ้ๆบ้ๆ ท G=1000 | ๅ
จ้ G=5000 | |
| | scGPT ็นๅพ๏ผ่พ
ๅฉ็ๆ็ฎๆ ๏ผ | ๅป็ปๆๅ target ็นๅพ `z_target` ไฝไธบ latent ๆต็็ๆ็ฎๆ | **ไธไฝฟ็จ**๏ผๆจกๅไปๅชๅฃฐ่ช่ก็ๆ latent๏ผStage 1๏ผ | |
| | ๆถ้ดๆญฅ | ็บง่้ๆ ท๏ผ40% ่ฎญ็ป latent, 60% ่ฎญ็ป่กจ่พพ | ไธค้ถๆฎตไธฒ่ก๏ผๅ
latent(0โ1), ๅ่กจ่พพ(0โ1) | |
| | ๆต้ๆ ท | ๅๆญฅ๏ผ`x_t = (1-t)*noise + t*target` | ODE ็งฏๅ๏ผRK4, 20 ๆญฅ | |
| | Loss | MSE(velocity) + MMD | ๆ | |
| | ่พๅบ | scalar loss | `(B, G_full)` ่กจ่พพ็ฉ้ต | |
| | ๆกไปถไฟกๅท | control + pert_id๏ผ็ๆกไปถ๏ผ๏ผscGPT ็นๅพๆฏ็ๆ็ฎๆ | control + pert_id๏ผๆฏๆญฅ่พๅ
ฅ๏ผ๏ผlatent ็ฑ Stage1 ็ๆ | |
| | ๆถ้ดๆญฅ | `t_expr` ๅ `t_latent` ้ๆบ๏ผไบๆฅๆฟๆดป | Stage1: `t_expr=0, t_latentโ[0,1]`; Stage2: `t_latent=1, t_exprโ[0,1]` | |
|
|
| --- |
|
|
| ## ไบใๆจกๅๆถๆๆป่งๅพ |
|
|
| ``` |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| โ CascadedFlowModel โ |
| โ โ |
| gene_id (B,G) โโโโโโโโโ GeneEncoder โโโ gene_emb (B,G,d) โ |
| โ โ โ |
| x_t (B,G) โโโโโโโโโโโโ ValEnc1 โโโ val_emb_1 (B,G,d) ๅชๅฃฐtarget โ |
| source (B,G) โโโโโโโโโโ ValEnc2 โโโ val_emb_2 (B,G,d) control โ |
| โ โ โ |
| โ fusion_layer(cat[val_emb_1, val_emb_2]) โ |
| โ + gene_emb (่ๅๅๅ ไธๆฌก) โ |
| โ โ โ |
| โ expr_tokens (B,G,d) โ |
| โ โ โ |
| z_t (B,G,512) โโโโโโโโ LatentEmbedder(512โ128โd) โ |
| โ โ โ |
| โ latent_tokens (B,G,d) โ |
| โ โ โ |
| โ x = expr_tokens + latent_tokens (B,G,d) โ |
| โ โ |
| t_expr (B,) โโโโโโโโโโ TimestepEmb โโโ โ |
| t_latent (B,) โโโโโโโโ TimestepEmb โโโผโ c = sum (B,d) โ |
| pert_id (B,2) โโโโโโโโ PertEmb โโโโโโโ โ |
| โ โ |
| โ โโ 4x DiffPerceiverBlock โโโโโโโโโโโโโโโ โ |
| โ โ gene_adaLN(gene_emb, x) โ โ |
| โ โ cat[x, pert_emb] โ adapter โ x โ โ |
| โ โ DiffPerceiverBlock(x, val_emb_2, c) โ โ |
| โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ |
| โ โ โ |
| โ โโโโ ExprDecoder(cat[x, pert]) โโโ pred_v_expr (B,G) |
| โ โ โ |
| โ โโโโ LatentDecoder(x, c) โ |
| โ dh_proj โ 2x AdaLN Block โ |
| โ โ final proj โโโ pred_v_latent (B,G,512) |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| ``` |
|
|