Skip to content

Commit

Permalink
resolved #336
Browse files Browse the repository at this point in the history
  • Loading branch information
hvgazula committed Jun 10, 2024
1 parent a8e960b commit f0396cb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nobrainer/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def from_tfrecords(
ds_obj.map_labels(
label_mapping=label_mapping, num_parallel_calls=num_parallel_calls
)

ds_obj.filter_zero_volumes()
# TODO automatically determine batch size
ds_obj.batch(1)

Expand Down Expand Up @@ -385,3 +387,9 @@ def repeat(self, n_repeats):
# through once.
self.dataset = self.dataset.repeat(n_repeats)
return self

def filter_zero_volumes(self):
self.dataset = self.dataset.filter(
lambda x, y: tf.cast(tf.math.reduce_sum(y), dtype="bool")
)
return self

0 comments on commit f0396cb

Please sign in to comment.