SURE-tools 2.1.18__py3-none-any.whl → 2.1.20__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of SURE-tools might be problematic. Click here for more details.

SURE/PerturbFlow.py CHANGED
@@ -10,7 +10,7 @@ from torch.distributions.utils import logits_to_probs, probs_to_logits, clamp_pr
10
10
  from torch.distributions import constraints
11
11
  from torch.distributions.transforms import SoftmaxTransform
12
12
 
13
- from .utils.custom_mlp import MLP, Exp
13
+ from .utils.custom_mlp import MLP, Exp, ZeroBiasMLP
14
14
  from .utils.utils import CustomDataset, CustomDataset2, CustomDataset4, tensor_to_numpy, convert_to_tensor
15
15
 
16
16
 
@@ -196,16 +196,20 @@ class PerturbFlow(nn.Module):
196
196
  if self.cell_factor_size>0:
197
197
  self.cell_factor_effect = nn.ModuleList()
198
198
  for i in np.arange(self.cell_factor_size):
199
- self.cell_factor_effect.append(MLP(
200
- [self.latent_dim+1] + hidden_sizes + [self.latent_dim],
201
- activation=activate_fct,
202
- output_activation=None,
203
- post_layer_fct=post_layer_fct,
204
- post_act_fct=post_act_fct,
205
- allow_broadcast=self.allow_broadcast,
206
- use_cuda=self.use_cuda,
207
- bias=False,
208
- )
199
+ #self.cell_factor_effect.append(MLP(
200
+ # [self.latent_dim+1] + hidden_sizes + [self.latent_dim],
201
+ # activation=activate_fct,
202
+ # output_activation=None,
203
+ # post_layer_fct=post_layer_fct,
204
+ # post_act_fct=post_act_fct,
205
+ # allow_broadcast=self.allow_broadcast,
206
+ # use_cuda=self.use_cuda,
207
+ # bias=False,
208
+ #)
209
+ #)
210
+ self.cell_factor_effect.append(ZeroBiasMLP(
211
+ self.latent_dim+1, hidden_sizes, self.latent_dim,
212
+ )
209
213
  )
210
214
 
211
215
  self.decoder_concentrate = MLP(
@@ -663,15 +667,15 @@ class PerturbFlow(nn.Module):
663
667
  cb = tensor_to_numpy(cb)
664
668
  return cb
665
669
 
666
- def _get_basis_embedding(self, xs):
670
+ def _get_basal_embedding(self, xs):
667
671
  zns, _ = self.encoder_zn(xs)
668
672
  return zns
669
673
 
670
- def get_basis_embedding(self,
674
+ def get_basal_embedding(self,
671
675
  xs,
672
676
  batch_size: int = 1024):
673
677
  """
674
- Return cells' basis latent representations
678
+ Return cells' basal latent representations
675
679
 
676
680
  Parameters
677
681
  ----------
@@ -692,7 +696,7 @@ class PerturbFlow(nn.Module):
692
696
  Z = []
693
697
  with tqdm(total=len(dataloader), desc='', unit='batch') as pbar:
694
698
  for X_batch, _ in dataloader:
695
- zns = self._get_basis_embedding(X_batch)
699
+ zns = self._get_basal_embedding(X_batch)
696
700
  Z.append(tensor_to_numpy(zns))
697
701
  pbar.update(1)
698
702
 
SURE/utils/custom_mlp.py CHANGED
@@ -209,3 +209,27 @@ class MLP(nn.Module):
209
209
  # pass through our sequential for the output!
210
210
  def forward(self, *args, **kwargs):
211
211
  return self.sequential_mlp.forward(*args, **kwargs)
212
+
213
+
214
+
215
+ class ZeroBiasMLP(nn.Module):
216
+ def __init__(self, input_dim, hidden_dims, output_dim):
217
+ super().__init__()
218
+ layers = []
219
+ dims = [input_dim] + hidden_dims + [output_dim]
220
+
221
+ # 构建线性层(强制所有偏置为0)
222
+ for i in range(len(dims)-1):
223
+ linear = nn.Linear(dims[i], dims[i+1])
224
+ nn.init.zeros_(linear.bias) # 初始化偏置为0
225
+ layers.append(linear)
226
+ if i < len(dims)-2:
227
+ layers.append(nn.ReLU()) # 激活函数
228
+
229
+ self.net = nn.Sequential(*layers)
230
+
231
+ def forward(self, x):
232
+ if type(x) == list:
233
+ x = torch.concat(x, dim=1)
234
+ return self.net(x)
235
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SURE-tools
3
- Version: 2.1.18
3
+ Version: 2.1.20
4
4
  Summary: Succinct Representation of Single Cells
5
5
  Home-page: https://github.com/ZengFLab/SURE
6
6
  Author: Feng Zeng
@@ -1,4 +1,4 @@
1
- SURE/PerturbFlow.py,sha256=WNOKfRsaK-TSIhOHY9DqbT_h8mxvbUEFnkevlsc4Kz8,50957
1
+ SURE/PerturbFlow.py,sha256=f0GUWbud-XDc3j0S3QKiRiUKr4cvtO9acoFyzMTH9eI,51151
2
2
  SURE/SURE.py,sha256=6qjf9E9OMBkZQSNnmvornpEa4E203-_rtz5Hs8jNCJA,47472
3
3
  SURE/SURE2.py,sha256=8wlnMwb1xuf9QUksNkWdWx5ZWq-xIy9NLx8RdUnE82o,48501
4
4
  SURE/__init__.py,sha256=NOJI_K-eCqPgStXXvgl3wIEMp6d8saMTDYLJ7Ga9MqE,293
@@ -16,12 +16,12 @@ SURE/flow/quiver.py,sha256=_euFqSaRrDoZ_oOabOx20LOoUTJ__XPhLW-vzLNQfAo,1859
16
16
  SURE/perturb/__init__.py,sha256=ouxShhbxZM4r5Gf7GmKiutrsmtyq7QL8rHjhgF0BU08,32
17
17
  SURE/perturb/perturb.py,sha256=CqO3xPfNA3cG175tadDidKvGsTu_yKfJRRLn_93awKM,3303
18
18
  SURE/utils/__init__.py,sha256=Htqv4KqVKcRiaaTBsR-6yZ4LSlbhbzutjNKXGD9-uds,660
19
- SURE/utils/custom_mlp.py,sha256=n0GJj8GKSAqvyokCL_6LugbeedzqLdfBijq24B_I9dA,7113
19
+ SURE/utils/custom_mlp.py,sha256=R63nhhRIO0sIEPwq7gAaBSDn5I5KMv7uDXsW6xEZXHw,7823
20
20
  SURE/utils/queue.py,sha256=E_5PA5EWcBoGAZj8BkKQnkCK0p4C-4-xcTPqdIXaPXU,1892
21
21
  SURE/utils/utils.py,sha256=IUHjDDtYaAYllCWsZyIzqQwaLul6fJRvHRH4vIYcR-c,8462
22
- sure_tools-2.1.18.dist-info/licenses/LICENSE,sha256=TFHKwmrAViXQbSX5W-NDItkWFjm45HWOeUniDrqmnu0,1065
23
- sure_tools-2.1.18.dist-info/METADATA,sha256=0MihooSGgEzdqyMlqUufrBjjtGURijDa7auUyE9extA,2651
24
- sure_tools-2.1.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- sure_tools-2.1.18.dist-info/entry_points.txt,sha256=-nJI8rVe_qqrR0HmfAODzj-JNfEqCcSsyVh6okSqyHk,83
26
- sure_tools-2.1.18.dist-info/top_level.txt,sha256=BtFTebdiJeqra4r6mm-uEtwVRFLZ_IjYsQ7OnalrOvY,5
27
- sure_tools-2.1.18.dist-info/RECORD,,
22
+ sure_tools-2.1.20.dist-info/licenses/LICENSE,sha256=TFHKwmrAViXQbSX5W-NDItkWFjm45HWOeUniDrqmnu0,1065
23
+ sure_tools-2.1.20.dist-info/METADATA,sha256=TWnbf7P62fec9iUnT2i8PZXuY9tMNL76_1uWS0j37rY,2651
24
+ sure_tools-2.1.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
+ sure_tools-2.1.20.dist-info/entry_points.txt,sha256=-nJI8rVe_qqrR0HmfAODzj-JNfEqCcSsyVh6okSqyHk,83
26
+ sure_tools-2.1.20.dist-info/top_level.txt,sha256=BtFTebdiJeqra4r6mm-uEtwVRFLZ_IjYsQ7OnalrOvY,5
27
+ sure_tools-2.1.20.dist-info/RECORD,,