Skip to content

Commit

Permalink
Freeze to Transformers 4.0
Browse files Browse the repository at this point in the history
Remove warnings + errors caused by deprecations
  • Loading branch information
Benjamin Hoover committed Dec 3, 2020
1 parent 455a210 commit e4dc140
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# secrets detector
.secrets.baseline

Expand Down Expand Up @@ -123,6 +124,7 @@ examples/data.xlsx
# custom folders
docs_source/_build/
docs_source/_modules/
notebooks/

.vscode
_archive
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
transformers>=2.5.0
torch>=1.3.0
transformers==4.0.0
torch==1.5.0
scipy==1.4.1
pandas==1.0.3
pandas==1.0.3
8 changes: 3 additions & 5 deletions rxnmapper/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,11 @@ def convert_batch_to_attns(

encoded_ids = self.tokenizer.batch_encode_plus(
rxn_smiles_list,
pad_to_max_length=True,
padding=True,
return_tensors="pt",
return_special_tokens_masks=True,
)
parsed_input = {
k: encoded_ids[k].to(self.device)
for k in ["input_ids", "token_type_ids", "attention_mask"]
parsed_input = {
k: v.to(self.device) for k, v in encoded_ids.items()
}
with torch.no_grad():
output = self.model(**parsed_input)
Expand Down
5 changes: 1 addition & 4 deletions rxnmapper/tokenization_smiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ def __init__(
**vocab_file**: Path to a SMILES character per line vocabulary file
"""
super().__init__(vocab_file, **kwargs)
# take into account special tokens in max length
self.max_len_single_sentence = self.max_len - 2
self.max_len_sentences_pair = self.max_len - 3

if not os.path.isfile(vocab_file):
raise ValueError(
Expand All @@ -60,7 +57,7 @@ def __init__(
[(ids, tok) for tok, ids in self.vocab.items()]
)
self.basic_tokenizer = BasicSmilesTokenizer()
self.init_kwargs["max_len"] = self.max_len
self.init_kwargs["model_max_length"] = self.model_max_length

@property
def vocab_size(self):
Expand Down

0 comments on commit e4dc140

Please sign in to comment.