Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Packages
chemical_checker
Commits
ed8949b3
Commit
ed8949b3
authored
Aug 10, 2021
by
Martino Bertoni
🌋
Browse files
SNN redict: first scale then trim
parent
9bd4b674
Pipeline
#2482
passed with stages
in 11 minutes and 31 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
package/chemicalchecker/tool/siamese/siamese_triplets.py
View file @
ed8949b3
...
...
@@ -869,21 +869,24 @@ class SiameseTriplets(object):
split(str): which split to predict.
batch_size(int): batch size for prediction.
"""
# apply input scaling
if
hasattr
(
self
,
'scaler'
):
scaled
=
self
.
scaler
.
transform
(
x_matrix
)
else
:
scaled
=
x_matrix
# apply trimming of input matrix
if
self
.
trim_mask
is
not
None
:
trimmed
=
x_matrix
[:,
np
.
repeat
(
self
.
trim_mask
,
128
)]
trimmed
=
scaled
[:,
np
.
repeat
(
self
.
trim_mask
,
128
)]
else
:
trimmed
=
x_matrix
trimmed
=
scaled
# load model if not alredy there
if
self
.
model
is
None
:
self
.
build_model
((
trimmed
.
shape
[
1
],),
load
=
True
,
cp
=
cp
)
# apply input scaling
if
hasattr
(
self
,
'scaler'
):
scaled
=
self
.
scaler
.
transform
(
trimmed
)
else
:
scaled
=
trimmed
# get rid of NaNs
no_nans
=
np
.
nan_to_num
(
scal
ed
)
no_nans
=
np
.
nan_to_num
(
trimm
ed
)
# get default dropout function
if
dropout_fn
is
None
:
return
self
.
transformer
.
predict
(
no_nans
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment