Skip to content

Commit

Permalink
BDSS Tree generator fixed (thanks to Manolo Perez)
Browse files Browse the repository at this point in the history
  • Loading branch information
annazhukova committed Oct 9, 2024
1 parent b03f3c4 commit 02fd0e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,4 @@ and 10, superspreading fraction between 0.05 and 0.20).
The time related parameters (infectious and eventually incubation period for BDEI model) are in the same units as the
branches of input tree, here in years (9.78 years). The covered parameter space for time related parameters is large
due to internal rescaling of all input trees. It should apply to any tree.

10 changes: 5 additions & 5 deletions phylodeep/model_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import pickle as pk
import warnings

import tensorflow as tf
tf.get_logger().setLevel('ERROR')

import numpy as np
from tensorflow import keras

warnings.filterwarnings('ignore')
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

PRETRAINED_MODELS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'pretrained_models')
PRETRAINED_PCA_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'pca_a_priori')
Expand Down Expand Up @@ -36,7 +36,7 @@ def model_scale_load_ffnn(tree_size, model):
# model_ffnn = keras.models.model_from_json(loaded_model)
# model_ffnn.load_weights(os.path.join(PRETRAINED_MODELS_DIR, 'weights',
# '{}_{}_{}.h5'.format(model, tree_size, pred_method)))
model_ffnn = keras.models.load_model(
model_ffnn = tf.keras.models.load_model(
os.path.join(PRETRAINED_MODELS_DIR, 'models', '{}_{}_{}.h5'.format(model, tree_size, pred_method)),
compile=False)

Expand All @@ -56,7 +56,7 @@ def model_load_cnn(tree_size, model):
# model_cnn = keras.models.model_from_json(loaded_model)
# model_cnn.load_weights(os.path.join(PRETRAINED_MODELS_DIR, 'weights',
# '{}_{}_{}.h5'.format(model, tree_size, pred_method)))
model_cnn = keras.models.load_model(
model_cnn = tf.keras.models.load_model(
os.path.join(PRETRAINED_MODELS_DIR, 'models', '{}_{}_{}.h5'.format(model, tree_size, pred_method)),
compile=False)

Expand Down
2 changes: 1 addition & 1 deletion simulators/bd_models/TreeGen_BDSS_refactored.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def removal(removed_type):
else:
nb_which_leaf = np.random.randint(0, metrics['number_inf2_leaves'])
which_leaf = leaves_dict['inf2_leaves'][nb_which_leaf]
leaves_dict['inf2_leaves'][nb_which_leaf]
del leaves_dict['inf2_leaves'][nb_which_leaf]
metrics['number_inf2_leaves'] -= 1

# which_leaf becomes a tip
Expand Down

0 comments on commit 02fd0e6

Please sign in to comment.