Skip to content

type ERROR #7

Description

@nicetheworld

Hi Thanks for this great resource,
when I use map functation of hnoca tools, I sucessfully run

 early_stopping_kwargs = {
    "early_stopping_metric": "val_loss",
    "mode": "min",
    "threshold": 0,
    "patience": 10,
    "reduce_lr": True,
    "lr_patience": 5,
    "lr_factor": 0.1,
}

mapper.map_query(
    adata_query_v1_hvg,
    retrain="partial",
    max_epochs=20,
    batch_size=256,
    unlabeled_prototype_training=False,
    n_epochs=10,
    pretraining_epochs=9,
    early_stopping_kwargs=early_stopping_kwargs,
    eta=10,
    alpha_epoch_anneal=10,
)

but when it comes to mapper.compute_wknn(k=100)
it get an error :

AttributeError Traceback (most recent call last)
Cell In[44], line 1
----> 1 mapper.compute_wknn(k=100)

File /ssd/software/miniconda3/envs/hnoca/lib/python3.10/site-packages/hnoca/map/mapper.py:198, in AtlasMapper.compute_wknn(self, ref_adata, k, query2ref, ref2query, ref_rep_key, query_rep_key, weighting_scheme, top_n)
196 self.ref_adata = ref_adata if ref_adata is not None else self.ref_adata
197 ref_latent = self._get_latent(self.query_model, self.ref_adata, key=ref_rep_key)
--> 198 query_latent = self._get_latent(
199 self.query_model, self.query_adata, key=query_rep_key
200 )
202 wknn = get_wknn(
203 ref=ref_latent,
204 query=query_latent,
(...)
209 top_n=top_n,
210 )
212 self.wknn = wknn

File /ssd/software/miniconda3/envs/hnoca/lib/python3.10/site-packages/hnoca/map/mapper.py:152, in AtlasMapper._get_latent(self, model, adata, key, **kwargs)
150 return model.get_latent_representation(adata, **kwargs)
151 if self.model_type == "scpoli":
--> 152 return model.get_latent(adata, **kwargs)

File /ssd/software/miniconda3/envs/hnoca/lib/python3.10/site-packages/scarches/models/scpoli/scpoli_model.py:354, in scPoli.get_latent(self, adata, mean)
352 subsampled_indices = indices.split(512)
353 for batch in subsampled_indices:
--> 354 x_batch = x[batch, :]
355 if sparse.issparse(x_batch):
356 x_batch = x_batch.toarray()

File /ssd/software/miniconda3/envs/hnoca/lib/python3.10/site-packages/scipy/sparse/_index.py:30, in IndexMixin.getitem(self, key)
29 def getitem(self, key):
---> 30 index, new_shape = self._validate_indices(key)
32 # 1D array
33 if len(index) == 1:

File /ssd/software/miniconda3/envs/hnoca/lib/python3.10/site-packages/scipy/sparse/_index.py:221, in IndexMixin._validate_indices(self, key)
219 index_1st.append(idx)
220 prelim_ndim += 1
--> 221 elif (ix := _compatible_boolean_index(idx, self.ndim)) is not None:
222 index_1st.append(ix)
223 prelim_ndim += ix.ndim

File /ssd/software/miniconda3/envs/hnoca/lib/python3.10/site-packages/scipy/sparse/_index.py:428, in _compatible_boolean_index(idx, desired_ndim)
425 # since first is boolean, construct array and check all elements
426 idx = np.asanyarray(idx)
--> 428 if idx.dtype.kind == 'b':
429 return idx
430 return None

AttributeError: 'torch.dtype' object has no attribute 'kind'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions