Skip to content

Can not use 'LightningModelEnsemble' to design sequences #110

@cdedonno

Description

@cdedonno

Hi @avantikalal,

I am trying to use the model ensemble function to design some elements. I am getting the following error:

  ---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  Cell In[13], line 23
        1 objective = Specificity(
        2     on_tasks = [
        3         'brain_ASCNT-1',
     (...)
       15     compare_func="subtract",
       16 )
       17 # unwanted_seqs = ['CG']
       18 # penalizer = PatternScore(
       19 #     patterns = unwanted_seqs, # Patterns to count
       20 #     weights=[-.1], # Score to assign to each occurrence of each pattern
       21 # )
  ---> 23 output = grelu.design.evolve(
       24     start_seq,
       25     model, 
       26     prediction_transform=objective,
       27     #seq_transform=penalizer,
       28     max_iter=2,
       29     num_workers=8,
       30     devices=0,
       31     return_seqs="all",
       32     for_each=True,
       33 )
  
  File /gpfs/scratchfs01/site/u/dedonnoc/mambaforge/gReLU/src/grelu/design.py:72, in evolve(seqs, model, method, patterns, prediction_transform, seq_transform, max_iter, positions, devices, num_workers, batch_size, genome, for_each, return_seqs, return_preds, verbose)
       69 best_score = -np.Inf
       71 # Add prediction transform
  ---> 72 model.add_transform(prediction_transform)
       74 # Give each starting sequence a unique ID
       75 start_seq_idxs = range(len(seqs))
  
  File ~/scratch/conda/envs/grelu_github/lib/python3.8/site-packages/torch/nn/modules/module.py:1709, in Module.__getattr__(self, name)
     1707     if name in modules:
     1708         return modules[name]
  -> 1709 raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
  
  AttributeError: 'LightningModelEnsemble' object has no attribute 'add_transform'

It seems that the class was not updated in a while, so maybe it is not compatible with the last refactors? Or am I doing something wrong on my end?

Thanks in advance.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions