lambo icon indicating copy to clipboard operation
lambo copied to clipboard

'NoneType' object

Open NeginManshour opened this issue 2 years ago • 1 comments

I have run the current version of the code with the below command:

python scripts/black_box_opt.py optimizer=lambo optimizer.encoder_obj=mlm task=proxy_rfp tokenizer=protein surrogate=multi_task_exact_gp acquisition=nehvi

and there is the full stack trace of the code with TypeError: 'NoneType' object is not iterable error.

wandb: Run `wandb offline` to turn off syncing.

logger:
  _target_: upcycle.logging.DataFrameLogger
  log_dir: data/experiments/test/summer-puddle-110/2023-05-01_06-34-09
task:
  _target_: lambo.tasks.proxy_rfp.proxy_rfp.ProxyRFPTask
  obj_dim: 2
  log_prefix: proxy_rfp
  batch_size: 16
  max_len: 244
  max_num_edits: null
  max_ngram_size: 1
  allow_len_change: false
  num_start_examples: 512
acquisition:
  _target_: lambo.acquisitions.ehvi.NoisyEHVI
  num_samples: 2
  batch_size: 16
encoder:
  _target_: lambo.models.lm_elements.LanguageModel
  name: mlm_cnn
  model:
    _target_: lambo.models.shared_elements.mCNN
    tokenizer:
      _target_: lambo.utils.ResidueTokenizer
    max_len: 244
    embed_dim: 64
    latent_dim: 16
    out_dim: 16
    kernel_size: 5
    p: 0.0
    layernorm: true
    max_len_delta: 0
  batch_size: 32
  num_epochs: 128
  patience: 32
  lr: 0.001
  max_shift: 0
  mask_ratio: 0.125
optimizer:
  _target_: lambo.optimizers.lambo.LaMBO
  _recursive_: false
  num_rounds: 64
  num_gens: 16
  num_opt_steps: 32
  patience: 32
  lr: 0.1
  concentrate_pool: 1
  mask_ratio: 0.125
  resampling_weight: 1.0
  encoder_obj: mlm
  optimize_latent: true
  position_sampler: uniform
  entropy_penalty: 0.01
  window_size: 1
  latent_init: null
  algorithm:
    _target_: pymoo.algorithms.soo.nonconvex.ga.GA
    pop_size: 16
    n_offsprings: null
    sampling:
      _target_: lambo.optimizers.sampler.BatchSampler
      batch_size: 16
    crossover:
      _target_: lambo.optimizers.crossover.BatchCrossover
      prob: 0.25
      prob_per_query: 0.25
    mutation:
      _target_: lambo.optimizers.mutation.LocalMutation
      prob: 1.0
      eta: 16
      safe_mut: false
    eliminate_duplicates: true
tokenizer:
  _target_: lambo.utils.ResidueTokenizer
surrogate:
  _target_: lambo.models.gp_models.MultiTaskExactGP
  max_shift: 0
  mask_size: 0
  bootstrap_ratio: null
  min_num_train: 128
  task_noise_init: 0.25
  gp_lr: 0.005
  enc_lr: 0.005
  bs: 32
  eval_bs: 16
  num_epochs: 256
  holdout_ratio: 0.2
  early_stopping: true
  patience: 32
  eval_period: 2
  out_dim: 2
  feature_dim: 16
  encoder_wd: 0.0001
  rank: null
  task_covar_prior:
    _target_: gpytorch.priors.LKJCovariancePrior
    'n': 2
    eta: 2.0
    sd_prior:
      _target_: gpytorch.priors.SmoothedBoxPrior
      a: 0.0001
      b: 1.0
  data_covar_module:
    _target_: gpytorch.kernels.MaternKernel
    ard_num_dims: 16
    lengthscale_prior:
      _target_: gpytorch.priors.NormalPrior
      loc: 0.7
      scale: 0.01
  likelihood:
    _target_: gpytorch.likelihoods.MultitaskGaussianLikelihood
    num_tasks: 2
    has_global_noise: false
    noise_constraint:
      _target_: gpytorch.constraints.GreaterThan
      lower_bound: 0.0001
seed: 0
trial_id: 0
project_name: lambo
version: v0.2.1
data_dir: data/experiments
exp_name: test
job_name: summer-puddle-110
timestamp: 2023-05-01_06-34-09
log_dir: data/experiments/test
wandb_mode: online
wandb_host: https://api.wandb.ai

GPU available: True
AdRed is non-dominated, adding to start pool
AdRed, [<lambo.utils.FoldxMutation object at 0x2aab699c5c70>]
DsRed.M1 is non-dominated, adding to start pool
DsRed.M1, [<lambo.utils.FoldxMutation object at 0x2aab69545a60>]
DsRed.T4 is non-dominated, adding to start pool
DsRed.T4, [<lambo.utils.FoldxMutation object at 0x2aab699fe580>]
RFP630 is non-dominated, adding to start pool
RFP630, [<lambo.utils.FoldxMutation object at 0x2aab6a1f4b20>]
mRouge is non-dominated, adding to start pool
mRouge, [<lambo.utils.FoldxMutation object at 0x2aab6a1f4b80>]
mScarlet is non-dominated, adding to start pool
mScarlet, [<lambo.utils.FoldxMutation object at 0x2aab6a1f4b80>]
[2023-05-01 06:34:37,890][root][ERROR] - 'NoneType' object is not iterable
Traceback (most recent call last):
  File "scripts/black_box_opt.py", line 56, in main
    metrics = optimizer.optimize(
  File "/storage/hpc/data/nmn5x/LAMBO/lambo/lambo/optimizers/lambo.py", line 75, in optimize
    is_feasible = self.bb_task.is_feasible(candidate_pool)
  File "/storage/hpc/data/nmn5x/LAMBO/lambo/lambo/tasks/base_task.py", line 72, in is_feasible
    is_feasible = np.array([len(cand) <= self.max_len for cand in candidates]).reshape(-1)
  File "/storage/hpc/data/nmn5x/LAMBO/lambo/lambo/tasks/base_task.py", line 72, in <listcomp>
    is_feasible = np.array([len(cand) <= self.max_len for cand in candidates]).reshape(-1)
  File "/storage/hpc/data/nmn5x/LAMBO/lambo/lambo/candidate.py", line 147, in __len__
    tok_idxs = self.tokenizer.encode(self.mutant_residue_seq)
  File "/storage/hpc/data/nmn5x/miniconda/envs/lambo-env-lewis/lib/python3.8/site-packages/cachetools/__init__.py", line 642, in wrapper
    v = func(*args, **kwargs)
  File "/storage/hpc/data/nmn5x/LAMBO/lambo/lambo/utils.py", line 63, in encode
    for char in seq:
TypeError: 'NoneType' object is not iterable

I would be very grateful if you guide me in this order. Thank you!

NeginManshour avatar May 01 '23 12:05 NeginManshour

I ran the same command and got different output. Most likely this is the result of a misconfigured environment or FoldX wasn't properly installed

logger:
  _target_: upcycle.logging.DataFrameLogger
  log_dir: data/experiments/test/comfy-hill-96/2023-05-01_08-08-06
task:
  _target_: lambo.tasks.proxy_rfp.proxy_rfp.ProxyRFPTask
  obj_dim: 2
  log_prefix: proxy_rfp
  batch_size: 16
  max_len: 244
  max_num_edits: null
  max_ngram_size: 1
  allow_len_change: false
  num_start_examples: 512
acquisition:
  _target_: lambo.acquisitions.ehvi.NoisyEHVI
  num_samples: 2
  batch_size: 16
encoder:
  _target_: lambo.models.lm_elements.LanguageModel
  name: mlm_cnn
  model:
    _target_: lambo.models.shared_elements.mCNN
    tokenizer:
      _target_: lambo.utils.ResidueTokenizer
    max_len: 244
    embed_dim: 64
    latent_dim: 16
    out_dim: 16
    kernel_size: 5
    p: 0.0
    layernorm: true
    max_len_delta: 0
  batch_size: 32
  num_epochs: 128
  patience: 32
  lr: 0.001
  max_shift: 0
  mask_ratio: 0.125
optimizer:
  _target_: lambo.optimizers.lambo.LaMBO
  _recursive_: false
  num_rounds: 64
  num_gens: 16
  num_opt_steps: 32
  patience: 32
  lr: 0.1
  concentrate_pool: 1
  mask_ratio: 0.125
  resampling_weight: 1.0
  encoder_obj: mlm
  optimize_latent: true
  position_sampler: uniform
  entropy_penalty: 0.01
  window_size: 1
  latent_init: null
  algorithm:
    _target_: pymoo.algorithms.soo.nonconvex.ga.GA
    pop_size: 16
    n_offsprings: null
    sampling:
      _target_: lambo.optimizers.sampler.BatchSampler
      batch_size: 16
    crossover:
      _target_: lambo.optimizers.crossover.BatchCrossover
      prob: 0.25
      prob_per_query: 0.25
    mutation:
      _target_: lambo.optimizers.mutation.LocalMutation
      prob: 1.0
      eta: 16
      safe_mut: false
    eliminate_duplicates: true
tokenizer:
  _target_: lambo.utils.ResidueTokenizer
surrogate:
  _target_: lambo.models.gp_models.MultiTaskExactGP
  max_shift: 0
  mask_size: 0
  bootstrap_ratio: null
  min_num_train: 128
  task_noise_init: 0.25
  gp_lr: 0.005
  enc_lr: 0.005
  bs: 32
  eval_bs: 16
  num_epochs: 256
  holdout_ratio: 0.2
  early_stopping: true
  patience: 32
  eval_period: 2
  out_dim: 2
  feature_dim: 16
  encoder_wd: 0.0001
  rank: null
  task_covar_prior:
    _target_: gpytorch.priors.LKJCovariancePrior
    'n': 2
    eta: 2.0
    sd_prior:
      _target_: gpytorch.priors.SmoothedBoxPrior
      a: 0.0001
      b: 1.0
  data_covar_module:
    _target_: gpytorch.kernels.MaternKernel
    ard_num_dims: 16
    lengthscale_prior:
      _target_: gpytorch.priors.NormalPrior
      loc: 0.7
      scale: 0.01
  likelihood:
    _target_: gpytorch.likelihoods.MultitaskGaussianLikelihood
    num_tasks: 2
    has_global_noise: false
    noise_constraint:
      _target_: gpytorch.constraints.GreaterThan
      lower_bound: 0.0001
seed: 0
trial_id: 0
project_name: lambo
version: v0.2.1
data_dir: data/experiments
exp_name: test
job_name: comfy-hill-96
timestamp: 2023-05-01_08-08-06
log_dir: data/experiments/test
wandb_mode: online
wandb_host: https://api.wandb.ai

GPU available: True
AdRed is non-dominated, adding to start pool
DsRed.M1 is non-dominated, adding to start pool
DsRed.T4 is non-dominated, adding to start pool
RFP630 is non-dominated, adding to start pool
mRouge is non-dominated, adding to start pool
mScarlet is non-dominated, adding to start pool
[-0.11583198  0.46189176]
|    |   round_idx |   hypervol_abs |   hypervol_rel |   num_bb_evals |   time_elapsed |
|---:|------------:|---------------:|---------------:|---------------:|---------------:|
|  0 |      0.0000 |         0.6751 |         1.0000 |         0.0000 |         0.0253 |

 best candidates
|    |   obj_val_0 |   obj_val_1 |
|---:|------------:|------------:|
|  0 | -11558.6276 |    -71.4708 |

active set contracted to 6 pareto points
active set augmented with 0 random points
[-10258.66136409     39.81466   ]
[[-11189.00587946    -39.8155    ]
 [-10376.84011515    -71.4708    ]
 [-10820.91136186    -55.6143    ]
 [-11558.62762577     29.6978    ]
 [-11445.82982225    -27.9617    ]
 [-10591.87684184    -61.8757    ]]
LSKHGLTKDMTMKYRMEGCVDGHKFVITGHGNGSPFEGKQTINLCVVEGGPLPFSEDILSAVFNRVFTDYPQGMVDFFKNSCPAGYTWQRSLLFEDGAVCTASADITVSVEENCFYHESKFHGVNFPADGPVMKKMTINWEPCCEKIIPVPRQGILKGDVAMYLLLKDGGRYRCQFDTVYKAKTDSKKMPEWHFIQHKLTREDRSDAKNQKWQLAEHSVASRSALA
TEDVIKEFMQFKVRMEGSVNGHYFEIEGEGEGKPYEGTQTAKLQVTKGGPLPFAWDILSPQFSKAYVKHPADIPDYMKLSFPEGFTWERSMNFEDGGVVEVQQDSSLQDGTFIYKVKFKGVNFPADGPVMQKKTAGWEPSTEKLYPQDGVLKGEISHALKLKDGGHYTCDFKTVYKAKKPVQLPGNHYVDSKLDITNHNEDYTVVEQYEHAEARHSG
VIKEFMRFKVRMEGSVNGHEFEIEGEGEGRPYEGTQTAKLKVTKGGPLPFAWDILSPQFSKVYVKHPADIPDYKKLSFPEGFKWERVMNFEDGGVVTVTQDSSLQDGCFIYKVKFIGVNFPSDGPVMQKKTMGWEPSTERLYPRDGVLKGEIHKALKLKDGGHYLVEFKSIYMAKKPVQLPGYYYVDSKLDITSHNEDYTIVEQYERAEGRHHLFL
MNSLIKENMRMMVVEGSVNGYQFKCTGEGDGNPYMGTQTMRIKVVEGGPLPFAFDILATSFSKTFIKHTKGIPDFFKQSFPEGFTWERVTRYEDGGVFTVMQDTSLEDGCLVYHAKVRGVNFPSNGAVMQKKTKGWEPSTEMLYPADGGLRGYSQMALNVDGGGYLSCSFETTYRSKKTVENFKMPGFHFVDHRLERLEESDKEMFVVQHEHAVAKFCDLPSKLGRL
EEDNMAIIKEFMRFKTHMEGSVNGHEFEIEGEGEGRPYEGTQTAKLKVTKGGPLPFAWDILSPQFSKAYVKHPADIPDYLKLSFPEGFKWERVMNFEDGGVVTVTQDSSLQDGEFIYKVKLRGTNFPSDGPVMQKKTMGWEACSERMYPEDGALKGEMKMRLKLKDGGHYDAEVKTTYKAKKPVQLPGAYNTNTKLDITSHNEDYTIVEQYERNEGRHSTGGMDELYK
AVIKEFMRFKVHMEGSMNGHEFEIEGEGEGRPYEGTQTAKLKVTKGGPLPFSWDILSPQFSRAFTKHPADIPDYYKQSFPEGFKWERVMNFEDGGAVTVTQDTSLEDGTLIYKVKLRGTNFPPDGPVMQKKTMGWEASTERLYPEDGVLKGDIKMALRLKDGGRYLADFKTTYKAKKPVQMPGAYNVDRKLDITSHNEDYTVVEQYERSEGRHSTG

---- fitting surrogate model ----
440 train, 53 val, 64 test

---- preparing checkpoint ----
starting val NLL: 0.3491

---- fitting all params ----

samuelstanton avatar May 01 '23 15:05 samuelstanton

closing due to inactivity

samuelstanton avatar Apr 20 '24 06:04 samuelstanton