def train(self):
    if (self.conf.reload_step > 0):
        self.reload(self.conf.reload_step)
    if (self.conf.data_type == '2D'):
        train_reader = H5DataLoader((self.conf.data_dir + self.conf.train_data))
        valid_reader = H5DataLoader((self.conf.data_dir + self.conf.valid_data))
    else:
        train_reader = H53DDataLoader((self.conf.data_dir + self.conf.train_data), self.input_shape)
        valid_reader = H53DDataLoader((self.conf.data_dir + self.conf.valid_data), self.input_shape)
    for epoch_num in range((self.conf.max_step + 1)):
        if (epoch_num and ((epoch_num % self.conf.test_interval) == 0)):
            (inputs, labels) = valid_reader.next_batch(self.conf.batch)
            feed_dict = {self.inputs: inputs, self.labels: labels}
            (loss, summary) = self.sess.run([self.loss_op, self.valid_summary], feed_dict=feed_dict)
            self.save_summary(summary, (epoch_num + self.conf.reload_step))
            print('----testing loss', loss)
        if (epoch_num and ((epoch_num % self.conf.summary_interval) == 0)):
            (inputs, labels) = train_reader.next_batch(self.conf.batch)
            feed_dict = {self.inputs: inputs, self.labels: labels}
            (loss, _, summary) = self.sess.run([self.loss_op, self.train_op, self.train_summary], feed_dict=feed_dict)
            self.save_summary(summary, (epoch_num + self.conf.reload_step))
        else:
            (inputs, labels) = train_reader.next_batch(self.conf.batch)
            feed_dict = {self.inputs: inputs, self.labels: labels}
            (loss, _) = self.sess.run([self.loss_op, self.train_op], feed_dict=feed_dict)
            print('----training loss', loss)
        if (epoch_num and ((epoch_num % self.conf.save_interval) == 0)):
            self.save((epoch_num + self.conf.reload_step))
def train(self):
    if (self.conf.reload_step > 0):
        self.reload(self.conf.reload_step)
    if (self.conf.data_type == '2D'):
        train_reader = H5DataLoader((self.conf.data_dir + self.conf.train_data))
        valid_reader = H5DataLoader((self.conf.data_dir + self.conf.valid_data))
    else:
        train_reader = H53DDataLoader((self.conf.data_dir + self.conf.train_data), self.input_shape)
        valid_reader = H53DDataLoader((self.conf.data_dir + self.conf.valid_data), self.input_shape)
    for epoch_num in range((self.conf.max_step + 1)):
        if (epoch_num and ((epoch_num % self.conf.test_interval) == 0)):
            (inputs, labels) = valid_reader.next_batch(self.conf.batch)
            feed_dict = {self.inputs: inputs, self.labels: labels}
            (loss, summary) = self.sess.run([self.loss_op, self.valid_summary], feed_dict=feed_dict)
            self.save_summary(summary, (epoch_num + self.conf.reload_step))
            print('----testing loss', loss)
        if (epoch_num and ((epoch_num % self.conf.summary_interval) == 0)):
            (inputs, labels) = train_reader.next_batch(self.conf.batch)
            feed_dict = {self.inputs: inputs, self.labels: labels}
            (loss, _, summary) = self.sess.run([self.loss_op, self.train_op, self.train_summary], feed_dict=feed_dict)
            self.save_summary(summary, (epoch_num + self.conf.reload_step))
        else:
            (inputs, labels) = train_reader.next_batch(self.conf.batch)
            feed_dict = {self.inputs: inputs, self.labels: labels}
            (loss, _) = self.sess.run([self.loss_op, self.train_op], feed_dict=feed_dict)
            print('----training loss', loss)
        if (epoch_num and ((epoch_num % self.conf.save_interval) == 0)):
            self.save((epoch_num + self.conf.reload_step))