Skip to content

Commit

Permalink
fixed prediction bug at bigger batch sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
rschwess committed May 24, 2021
1 parent 5f0f6ff commit caf15e4
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def predict(sess,
test_batch_end = step * FLAGS.batch_size + FLAGS.batch_size
test_batch_range=range(test_batch_start, test_batch_end)
feed_dict = {
seqs_placeholder: np.expand_dims(seqs[test_batch_range][0], axis=0),
seqs_placeholder: seqs[test_batch_range],
keep_prob_inner_placeholder: 1.0,
keep_prob_outer_placeholder: 1.0
}
Expand Down
2 changes: 1 addition & 1 deletion legacy_version_tf1.8/run_deploy_shape_deepCregr.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def predict(sess,
test_batch_end = step * FLAGS.batch_size + FLAGS.batch_size
test_batch_range=range(test_batch_start, test_batch_end)
feed_dict = {
seqs_placeholder: np.expand_dims(seqs[test_batch_range][0], axis=0),
seqs_placeholder: seqs[test_batch_range],
keep_prob_inner_placeholder: 1.0,
keep_prob_outer_placeholder: 1.0
}
Expand Down
4 changes: 2 additions & 2 deletions legacy_version_tf1.8/run_get_saliency.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''DESCRIPTION:
seqs_placeholder: seqs[test_batch_range],'''DESCRIPTION:
Run Get Saliency Scores: Gradient of Output with respect to inout and/or intermediate layers.
# FORMAT
chr start end replacer --> will work like variant deploy in terms of apllying variants
Expand Down Expand Up @@ -181,7 +181,7 @@ def map_saliency(sess,
test_batch_end = step * FLAGS.batch_size + FLAGS.batch_size
test_batch_range=range(test_batch_start, test_batch_end)
feed_dict = {
seqs_placeholder: np.expand_dims(seqs[test_batch_range][0], axis=0),
seqs_placeholder: seqs[test_batch_range],
keep_prob_inner_placeholder: 1.0,
keep_prob_outer_placeholder: 1.0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def predict(sess,
test_batch_end = step * FLAGS.batch_size + FLAGS.batch_size
test_batch_range=range(test_batch_start, test_batch_end)
feed_dict = {
seqs_placeholder: np.expand_dims(seqs[test_batch_range][0], axis=0),
seqs_placeholder: seqs[test_batch_range],
keep_prob_inner_placeholder: 1.0,
keep_prob_outer_placeholder: 1.0
}
Expand Down
2 changes: 1 addition & 1 deletion tensorflow1_version/run_deploy_shape_deepCregr.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def predict(sess,
test_batch_end = step * FLAGS.batch_size + FLAGS.batch_size
test_batch_range=range(test_batch_start, test_batch_end)
feed_dict = {
seqs_placeholder: np.expand_dims(seqs[test_batch_range][0], axis=0),
seqs_placeholder: seqs[test_batch_range],
keep_prob_inner_placeholder: 1.0,
keep_prob_outer_placeholder: 1.0
}
Expand Down
2 changes: 1 addition & 1 deletion tensorflow1_version/run_get_saliency.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def map_saliency(sess,
test_batch_end = step * FLAGS.batch_size + FLAGS.batch_size
test_batch_range=range(test_batch_start, test_batch_end)
feed_dict = {
seqs_placeholder: np.expand_dims(seqs[test_batch_range][0], axis=0),
seqs_placeholder: seqs[test_batch_range],
keep_prob_inner_placeholder: 1.0,
keep_prob_outer_placeholder: 1.0
}
Expand Down
6 changes: 3 additions & 3 deletions tensorflow1_version/run_training_deepCregr.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Basic model parameters as external flags -------------------------------------
flags = tf.app.flags
FLAGS = flags.FLAGS
flags.DEFINE_boolean('help', False, 'For help.')
# flags.DEFINE_boolean('help', False, 'For help.')
flags.DEFINE_string('data_file', '', 'Input data: pseudo bed format: chr start end and comma separated classes')
# TRAININGS SETTINGS
flags.DEFINE_string('test_chroms', 'chr12, chr13', 'Comma seperated list of test chromosoems to use ...')
Expand Down Expand Up @@ -76,8 +76,8 @@
BP_CONTEXT = FLAGS.bp_context
NUM_CLASSES = FLAGS.num_classes

if FLAGS.help:
print(FLAGS.__dict__['__flags'])
# if FLAGS.help:
# print(FLAGS.__dict__['__flags'])

# SET RANDOM SEED --------------------------------------------------------------
np.random.seed(FLAGS.seed) # use same seed for numpy --> for shuffeling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def predict(sess,
test_batch_end = step * FLAGS.batch_size + FLAGS.batch_size
test_batch_range=range(test_batch_start, test_batch_end)
feed_dict = {
seqs_placeholder: np.expand_dims(seqs[test_batch_range][0], axis=0),
seqs_placeholder: seqs[test_batch_range],
keep_prob_inner_placeholder: 1.0,
keep_prob_outer_placeholder: 1.0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def predict(sess,
test_batch_end = step * FLAGS.batch_size + FLAGS.batch_size
test_batch_range=range(test_batch_start, test_batch_end)
feed_dict = {
seqs_placeholder: np.expand_dims(seqs[test_batch_range][0], axis=0),
seqs_placeholder: seqs[test_batch_range],
keep_prob_inner_placeholder: 1.0,
keep_prob_outer_placeholder: 1.0
}
Expand Down
2 changes: 1 addition & 1 deletion tensorflow2.0_compatibility_version/run_get_saliency.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def map_saliency(sess,
test_batch_end = step * FLAGS.batch_size + FLAGS.batch_size
test_batch_range=range(test_batch_start, test_batch_end)
feed_dict = {
seqs_placeholder: np.expand_dims(seqs[test_batch_range][0], axis=0),
seqs_placeholder: seqs[test_batch_range],
keep_prob_inner_placeholder: 1.0,
keep_prob_outer_placeholder: 1.0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def predict(sess,
test_batch_end = step * FLAGS.batch_size + FLAGS.batch_size
test_batch_range=range(test_batch_start, test_batch_end)
feed_dict = {
seqs_placeholder: np.expand_dims(seqs[test_batch_range][0], axis=0),
seqs_placeholder: seqs[test_batch_range],
keep_prob_inner_placeholder: 1.0,
keep_prob_outer_placeholder: 1.0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,12 @@ def predict(sess,
js = patch_start + i * half_bin_size
je = patch_start + i * half_bin_size + FLAGS.bp_context
jseq = seq[(i*half_bin_size):((i)*half_bin_size + FLAGS.bp_context)]
run_starts.append(js)
run_ends.append(je)
run_seqs.append(jseq)
if len(jseq) == FLAGS.bp_context:
run_starts.append(js)
run_ends.append(je)
run_seqs.append(jseq)
else:
print('Extracted seq for %s-%s is smaller then bp_context ... skipping' % (js, je))
i += 1

# Predict ----------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def map_saliency(sess,
test_batch_end = step * FLAGS.batch_size + FLAGS.batch_size
test_batch_range=range(test_batch_start, test_batch_end)
feed_dict = {
seqs_placeholder: np.expand_dims(seqs[test_batch_range][0], axis=0),
seqs_placeholder: seqs[test_batch_range],
keep_prob_inner_placeholder: 1.0,
keep_prob_outer_placeholder: 1.0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
flags = tf.app.flags
FLAGS = flags.FLAGS

#flags.DEFINE_boolean('help', False, 'For help.')

flags.DEFINE_string('data_file', '', 'Input data: pseudo bed format: chr start end and comma separated classes')

# TRAININGS SETTINGS
Expand Down Expand Up @@ -82,9 +80,6 @@
BP_CONTEXT = FLAGS.bp_context
NUM_CLASSES = FLAGS.num_classes

#if FLAGS.help:
# print(FLAGS.__dict__['__flags'])

# SET RANDOM SEED --------------------------------------------------------------
np.random.seed(FLAGS.seed) # use same seed for numpy --> for shuffeling

Expand Down

0 comments on commit caf15e4

Please sign in to comment.