Hello again,
I am having trouble initializing a model using the code in "Tutorial 2: Training a Drug Property Prediction Model from Scratch for Assay Data". Here are the errors I'm getting:
config = utils.generate_config(drug_encoding = drug_encoding,
cls_hidden_dims = [1024,1024,512],
train_epoch = 5,
LR = 0.001,
batch_size = 128,
hidden_dim_drug = 128,
mpnn_hidden_size = 128,
mpnn_depth = 3
)
model = models.model_initialize(**config)
model
AttributeError Traceback (most recent call last)
in
----> 1 model = models.model_initialize(**config)
2 model
~\Dropbox\Work\insight\omic\DeepPurpose\DeepPurpose\DTI.py in model_initialize(**config)
57
58 def model_initialize(**config):
---> 59 model = DBTA(**config)
60 return model
61
~\Dropbox\Work\insight\omic\DeepPurpose\DeepPurpose\DTI.py in init(self, **config)
259 self.model_protein = transformer('protein', **config)
260 else:
--> 261 raise AttributeError('Please use one of the available encoding method.')
262
263 self.model = Classifier(self.model_drug, self.model_protein, **config)
AttributeError: Please use one of the available encoding method.
model.train(train, val, test)
Let's use CPU/s!
--- Data Preparation ---
--- Go for Training ---
KeyError Traceback (most recent call last)
C:\ProgramData\Anaconda3\envs\multiPurpose\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
2890 try:
-> 2891 return self._engine.get_loc(casted_key)
2892 except KeyError as err:
pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'target_encoding'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
in
----> 1 model.train(train, val, test)
~\Dropbox\Work\insight\omic\DeepPurpose\DeepPurpose\DTI.py in train(self, train, val, test, verbose)
392 t_start = time()
393 for epo in range(train_epoch):
--> 394 for i, (v_d, v_p, label) in enumerate(training_generator):
395 if self.target_encoding == 'Transformer':
396 v_p = v_p
C:\ProgramData\Anaconda3\envs\multiPurpose\lib\site-packages\torch\utils\data\dataloader.py in next(self)
343
344 def next(self):
--> 345 data = self._next_data()
346 self._num_yielded += 1
347 if self._dataset_kind == _DatasetKind.Iterable and \
C:\ProgramData\Anaconda3\envs\multiPurpose\lib\site-packages\torch\utils\data\dataloader.py in _next_data(self)
383 def _next_data(self):
384 index = self._next_index() # may raise StopIteration
--> 385 data = self._dataset_fetcher.fetch(index) # may raise StopIteration
386 if self._pin_memory:
387 data = _utils.pin_memory.pin_memory(data)
C:\ProgramData\Anaconda3\envs\multiPurpose\lib\site-packages\torch\utils\data_utils\fetch.py in fetch(self, possibly_batched_index)
42 def fetch(self, possibly_batched_index):
43 if self.auto_collation:
---> 44 data = [self.dataset[idx] for idx in possibly_batched_index]
45 else:
46 data = self.dataset[possibly_batched_index]
C:\ProgramData\Anaconda3\envs\multiPurpose\lib\site-packages\torch\utils\data_utils\fetch.py in (.0)
42 def fetch(self, possibly_batched_index):
43 if self.auto_collation:
---> 44 data = [self.dataset[idx] for idx in possibly_batched_index]
45 else:
46 data = self.dataset[possibly_batched_index]
~\Dropbox\Work\insight\omic\DeepPurpose\DeepPurpose\utils.py in getitem(self, index)
519 if self.config['drug_encoding'] == 'CNN' or self.config['drug_encoding'] == 'CNN_RNN':
520 v_d = drug_2_embed(v_d)
--> 521 v_p = self.df.iloc[index]['target_encoding']
522 if self.config['target_encoding'] == 'CNN' or self.config['target_encoding'] == 'CNN_RNN':
523 v_p = protein_2_embed(v_p)
C:\ProgramData\Anaconda3\envs\multiPurpose\lib\site-packages\pandas\core\series.py in getitem(self, key)
880
881 elif key_is_scalar:
--> 882 return self._get_value(key)
883
884 if (
C:\ProgramData\Anaconda3\envs\multiPurpose\lib\site-packages\pandas\core\series.py in _get_value(self, label, takeable)
989
990 # Similar to Index.get_value, but we do not fall back to positional
--> 991 loc = self.index.get_loc(label)
992 return self.index._get_values_for_loc(self, loc, label)
993
C:\ProgramData\Anaconda3\envs\multiPurpose\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
2891 return self._engine.get_loc(casted_key)
2892 except KeyError as err:
-> 2893 raise KeyError(key) from err
2894
2895 if tolerance is not None:
KeyError: 'target_encoding'