You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for sharing the source code. As mentioned in the title, upon executing the provided code, I observed that different values are returned for the same SMILES input. Would it be reasonable to consider this behavior as expected?
the code:
import torch
from build_vocab import WordVocab
from pretrain_trfm import TrfmSeq2seq
from utils import split
from transformers import T5EncoderModel, T5Tokenizer
import re
import gc
import numpy as np
import pandas as pd
import pickle
import math
def smiles_to_vec(Smiles):
pad_index = 0
unk_index = 1
eos_index = 2
sos_index = 3
mask_index = 4
vocab = WordVocab.load_vocab('vocab.pkl')
def get_inputs(sm):
seq_len = 220
sm = sm.split()
if len(sm)>218:
print('SMILES is too long ({:d})'.format(len(sm)))
sm = sm[:109]+sm[-109:]
ids = [vocab.stoi.get(token, unk_index) for token in sm]
ids = [sos_index] + ids + [eos_index]
seg = [1]*len(ids)
padding = [pad_index]*(seq_len - len(ids))
ids.extend(padding), seg.extend(padding)
return ids, seg
def get_array(smiles):
x_id, x_seg = [], []
for sm in smiles:
a,b = get_inputs(sm)
x_id.append(a)
x_seg.append(b)
return torch.tensor(x_id), torch.tensor(x_seg)
trfm = TrfmSeq2seq(len(vocab), 256, len(vocab), 4)
trfm.load_state_dict(torch.load('trfm_12_23000.pkl'))
trfm.eval()
x_split = [split(sm) for sm in Smiles]
xid, xseg = get_array(x_split)
print(f"xid: {xid}") # <-- ここまで同じ値
X = trfm.encode(torch.t(xid))
print(f"X: {X}") # <-- 違う値になってる
return X
Smiles = ['CC']*2
smiles_vec = smiles_to_vec(Smiles)
Dear developers,
Thank you for sharing the source code. As mentioned in the title, upon executing the provided code, I observed that different values are returned for the same SMILES input. Would it be reasonable to consider this behavior as expected?
the code:
the output is:
Here is the computational environment I used:
python 3.6.5
numpy 1.19.5
torch 1.10.1+cu113
nvidia V100
I apologize if I have overlooked anything as I am not extensively familiar with transformer architecture.
Sincerely,
The text was updated successfully, but these errors were encountered: