models/dense_net.py
def train_one_epoch(self, data, batch_size, learning_rate):
        """
        Trains the model for one epoch using data from the proper training set.

        Args:
            data: training data yielded by the dataset's data provider;
            batch_size: `int`, number of examples in a training batch;
            learning_rate: `int`, learning rate for the optimizer.
        """
        num_examples = data.num_examples
        total_loss = []
        total_accuracy = []

        # save each training batch's loss and accuracy
        for i in range(num_examples // batch_size):
            batch = data.next_batch(batch_size)
            images, labels = batch
            feed_dict = {
                self.images: images,
                self.labels: labels,
                self.learning_rate: learning_rate,
                self.is_training: True,
            }
            fetches = [self.train_step, self.cross_entropy[-1], self.accuracy]
            result = self.sess.run(fetches, feed_dict=feed_dict)
            _, loss, accuracy = result
            total_loss.append(loss)
            total_accuracy.append(accuracy)
            if self.should_save_logs:
                self.batches_step += 1
                self.log_loss_accuracy(
                    loss, accuracy, self.batches_step, prefix='per_batch',
                    should_print=False)

        # use the saved data to calculate the mean loss and accuracy
        mean_loss = np.mean(total_loss)
        mean_accuracy = np.mean(total_accuracy)
        return mean_loss, mean_accuracy

        Trains the model for one epoch using data from the proper training set.

        Args:
            data: training data yielded by the dataset's data provider;
            batch_size: `int`, number of examples in a training batch;
            learning_rate: `int`, learning rate for the optimizer.
        
Trains the model for one epoch using data from the proper training set.
Trains the model for one epoch using data from the proper training set .
def train_one_epoch(self, data, batch_size, learning_rate):
        num_examples = data.num_examples
        total_loss = []
        total_accuracy = []
        for i in range(num_examples // batch_size):
            batch = data.next_batch(batch_size)
            images, labels = batch
            feed_dict = {
                self.images: images,
                self.labels: labels,
                self.learning_rate: learning_rate,
                self.is_training: True,
            }
            fetches = [self.train_step, self.cross_entropy[-1], self.accuracy]
            result = self.sess.run(fetches, feed_dict=feed_dict)
            _, loss, accuracy = result
            total_loss.append(loss)
            total_accuracy.append(accuracy)
            if self.should_save_logs:
                self.batches_step += 1
                self.log_loss_accuracy(
                    loss, accuracy, self.batches_step, prefix='per_batch',
                    should_print=False)
        mean_loss = np.mean(total_loss)
        mean_accuracy = np.mean(total_accuracy)
        return mean_loss, mean_accuracy
def train_one_epoch ( self , data , batch_size , learning_rate ) : num_examples = data . num_examples total_loss = [ ] total_accuracy = [ ] for i in range ( num_examples // batch_size ) : batch = data . next_batch ( batch_size ) images , labels = batch feed_dict = { self . images : images , self . labels : labels , self . learning_rate : learning_rate , self . is_training : True , } fetches = [ self . train_step , self . cross_entropy [ - 1 ] , self . accuracy ] result = self . sess . run ( fetches , feed_dict = feed_dict ) _ , loss , accuracy = result total_loss . append ( loss ) total_accuracy . append ( accuracy ) if self . should_save_logs : self . batches_step += 1 self . log_loss_accuracy ( loss , accuracy , self . batches_step , prefix = 'per_batch' , should_print = False ) mean_loss = np . mean ( total_loss ) mean_accuracy = np . mean ( total_accuracy ) return mean_loss , mean_accuracy
Trains the model for one epoch using data from the proper training set.
Trains the model for one epoch using data from the proper training set .
"""
        Trains the model for one epoch using data from the proper training set.

        Args:
            data: training data yielded by the dataset's data provider;
            batch_size: `int`, number of examples in a training batch;
            learning_rate: `int`, learning rate for the optimizer.
        """ # save each training batch's loss and accuracy # use the saved data to calculate the mean loss and accuracy
self
data
training data yielded by the dataset's data provider.
training data yielded by the dataset ' s data provider .
batch_size
`int`, number of examples in a training batch.
` int ` number of examples in a training batch .
learning_rate
`int`, learning rate for the optimizer.
` int ` learning rate for the optimizer .