Skip to content

Commit

Permalink
Merge pull request #1 from CamiloPosso/py_37_tensorflow_2.0.0
Browse files Browse the repository at this point in the history
Updating denovo to tensorflow 2.0.0
  • Loading branch information
CamiloPosso authored Mar 15, 2023
2 parents 522a065 + 5e1ea99 commit f63edc6
Show file tree
Hide file tree
Showing 10 changed files with 241 additions and 151 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,14 @@ dmypy.json
docker log.txt
next steps from yuri.txt
cProfile.ipynb


## More ignores
.vscode/launch.json
Kaiko_denovo/src/kaiko_main_debugging.py
Kaiko_denovo/tf2.0.0_variable_names.txt
Kaiko_denovo_tf1.15.0


tf2.0.0_variable_names.txt
tf_updgrade_report.txt
1 change: 1 addition & 0 deletions Kaiko_denovo/VERSION INFO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is the denovo piece of Kaiko, being tested with tensorflow 2.0.0
15 changes: 8 additions & 7 deletions Kaiko_denovo/src/deepnovo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from six.moves import xrange

import numpy as np
import tensorflow as tf
# import tensorflow as tf
import tensorflow.compat.v1 as tf


# ==============================================================================
Expand All @@ -20,7 +21,7 @@


tf.app.flags.DEFINE_string("train_dir", # flag_name
"train", # default_value
"Kaiko_denovo/model/", # default_value
"Training directory.") # docstring

tf.app.flags.DEFINE_integer("direction",
Expand Down Expand Up @@ -63,7 +64,7 @@
"Knapsack input directory.")

tf.app.flags.DEFINE_boolean("multi_decode",
False,
True,
"Set to True for decoding multiple files.")

tf.app.flags.DEFINE_boolean("topk",
Expand Down Expand Up @@ -151,15 +152,15 @@
False,
"Set to True to search decoy database.")

tf.app.flags.DEFINE_boolean("profile",
False,
"Set to True to profile the denovo model")

FLAGS = tf.app.flags.FLAGS
"""
Kaiko cProfile addition
"""

tf.app.flags.DEFINE_boolean("profile",
False,
"Set to True to profile the denovo model")


# ==============================================================================
# GLOBAL VARIABLES for VOCABULARY
Expand Down
20 changes: 10 additions & 10 deletions Kaiko_denovo/src/deepnovo_main_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1978,14 +1978,14 @@ def create_model(session, training_mode):

# folder of training state
ckpt = tf.train.get_checkpoint_state(deepnovo_config.FLAGS.train_dir)
if ckpt and tf.gfile.Exists(ckpt.model_checkpoint_path+".index"):
if ckpt and tf.io.gfile.exists(ckpt.model_checkpoint_path+".index"):
print("Reading model parameters from %s" % ckpt.model_checkpoint_path)
model.saver.restore(session, ckpt.model_checkpoint_path)
else:
print("Created model with fresh parameters.")
#~ train_writer = tf.train.SummaryWriter("train_log", session.graph)
#~ train_writer.close()
session.run(tf.global_variables_initializer())
session.run(tf.compat.v1.global_variables_initializer())
return model


Expand Down Expand Up @@ -2893,7 +2893,7 @@ def decode_beam_search(sess,
def decode(input_file=deepnovo_config.decode_test_file):
"""TODO(nh2tran): docstring."""

with tf.Session() as sess:
with tf.compat.v1.Session() as sess:

# DECODING MODEL
print("DECODING MODEL")
Expand Down Expand Up @@ -3034,7 +3034,7 @@ def decode(input_file=deepnovo_config.decode_test_file):
def multi_decode(input_dir=deepnovo_config.input_mgf_dir):
"""TODO(nh2tran): docstring."""

with tf.Session() as sess:
with tf.compat.v1.Session() as sess:

# DECODING MODEL
print("DECODING MODEL")
Expand Down Expand Up @@ -3580,7 +3580,7 @@ def train():
#~ resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1000)

# TRAINING on train_set
with tf.Session() as sess:
with tf.compat.v1.Session() as sess:
#~ print("RESOURCE-sess: ",
#~ resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1000)

Expand Down Expand Up @@ -3691,7 +3691,7 @@ def test_true_feeding():
spectra_file_location_test)

# Testing
with tf.Session() as sess:
with tf.compat.v1.Session() as sess:

print("Create model for testing")
model = create_model(sess, training_mode=False)
Expand Down Expand Up @@ -3809,8 +3809,8 @@ def multi_train_for_sigopt(hyperparams,
valid_bucket_pos_id = np.nonzero(valid_bucket_len)[0]

# TRAINING on train_set
tf.reset_default_graph()
with tf.Session() as sess:
tf.compat.v1.reset_default_graph()
with tf.compat.v1.Session() as sess:
print("Create model for training")
model = create_model(sess, training_mode=True)

Expand Down Expand Up @@ -3931,7 +3931,7 @@ def multi_train():
valid_bucket_pos_id = np.nonzero(valid_bucket_len)[0]

# TRAINING on train_set
with tf.Session() as sess:
with tf.compat.v1.Session() as sess:
print("Create model for training")
model = create_model(sess, training_mode=True)

Expand Down Expand Up @@ -4328,7 +4328,7 @@ def multi_train_pickles():
valid_bucket_pos_id = np.nonzero(valid_bucket_len)[0]

# TRAINING on train_set
with tf.Session() as sess:
with tf.compat.v1.Session() as sess:
print("Create model for training")
model = create_model(sess, training_mode=True)

Expand Down
Loading

0 comments on commit f63edc6

Please sign in to comment.