using uniform sampler for validation curve
@@ -4,6 +4,8 @@ import tensorflow as tf
from niftynet.application.regression_application import \
RegressionApplication, SUPPORTED_INPUT
+from niftynet.engine.sampler_uniform import UniformSampler
+from niftynet.engine.sampler_weighted import WeightedSampler
from niftynet.engine.application_variables import NETWORK_OUTPUT
from niftynet.io.image_reader import ImageReader
from niftynet.layer.histogram_normalisation import \
@@ -15,6 +17,25 @@ from niftynet.layer.pad import PadLayer
class ISampleRegression(RegressionApplication):
+ def initialise_weighted_sampler(self):
+ if len(self.readers) == 2:
+ training_sampler = WeightedSampler(
+ reader=self.readers[0],
+ data_param=self.data_param,
+ batch_size=self.net_param.batch_size,
+ windows_per_image=self.action_param.sample_per_volume,
+ queue_length=self.net_param.queue_length)
+ validation_sampler = UniformSampler(
+ reader=self.readers[1],
+ data_param=self.data_param,
+ batch_size=self.net_param.batch_size,
+ windows_per_image=self.action_param.sample_per_volume,
+ queue_length=self.net_param.queue_length)
+ self.sampler = [[training_sampler, validation_sampler]]
+ else:
+ RegressionApplication.initialise_weighted_sampler()
+
+
def initialise_dataset_loader(
self, data_param=None, task_param=None, data_partitioner=None):
RegressionApplication.initialise_dataset_loader(
@@ -55,7 +76,6 @@ class ISampleRegression(RegressionApplication):
def connect_data_and_network(self,
outputs_collector=None,
gradients_collector=None):
-
if self.is_training:
# using the original training pipeline
RegressionApplication.connect_data_and_network(
