Skip to content

Commit

Permalink
add the mean and fix the output
Browse files Browse the repository at this point in the history
  • Loading branch information
carcablop committed Nov 30, 2023
1 parent 3b74e56 commit dee0bb8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM bentoml/model-server:0.11.0-py38
MAINTAINER ersilia

RUN pip install rdkit
#RUN pip install numpy==1.23.1
RUN pip install numpy==1.23.1
RUN pip install fastai==1.0.61
RUN pip install scikit-learn
RUN pip install spacy
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"Input Shape": "Single",
"Output": ["Other value"],
"Output Type": ["Float"],
"Output Shape": "Flexible List",
"Output Shape": "Matrix",
"Interpretation": "Embedding vectors of each smiles are obtained, represented in a matrix, where each row is a vector of embedding of each smiles character, with a dimension of 400. The pretrained model is loaded using the fastai library",
"Tag": [
"Descriptor",
Expand Down
7 changes: 4 additions & 3 deletions model/framework/code/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def my_model(smiles_list):
for smile in smiles_list:
smile_tokenizer=tokenizer.tokenizer(smile)
indices = [qsar_db.vocab.itos.index(token) for token in smile_tokenizer]
embes=embs_v1[indices][:, :100].numpy()
embes=embs_v1[indices][:, :].numpy()
embes = np.mean(embes, axis=0)
list_embeddings.append(embes)

return list_embeddings
Expand All @@ -91,8 +92,8 @@ def my_model(smiles_list):
# write output in a .csv file
with open(output_file, "w") as f:
writer = csv.writer(f)
writer.writerow(["embeddings"]) # header
writer.writerow(["emb-{0}".format(i) for i in range(400)]) # header
for o in outputs:
writer.writerow([o])
writer.writerow(list(o))


0 comments on commit dee0bb8

Please sign in to comment.