Trainer¶
This module contains the trainer code and other codes regarding training.
-
class
lenet.trainer.
trainer
(network, dataset)[source][source]¶ Trainer for networks
Parameters: - network – A network class object
- dataset – A tensorflow dataset object
-
network
[source]¶ This is the network we initialized with. We pass this as an argument and we add it to the current trainer class.
-
dataset
[source]¶ This is also the initializer. It comes from the
lenet.dataset.mnist
module.
-
tensorboard
[source]¶ Is a summary writer tool. This writes things into the tensorboard that is then setup on the tensorboard server. At the end of the trainer, it closes this tensorboard.
-
accuracy
(images, labels)[source][source]¶ Return accuracy
Parameters: - images – images
- labels – labels
Returns: accuracy
Return type: float
-
bp_step
(mini_batch_size)[source][source]¶ Sample a minibatch of data and run one step of BP.
Parameters: mini_batch_size – Integer Returns: total objective and cost of that step Return type: tuple of tensors
-
summaries
(name='tensorboard')[source][source]¶ Just creates a summary merge bufer
Parameters: name – a name for the tensorboard directory
-
train
(iter=10000, mini_batch_size=500, update_after_iter=1000, training_accuracy=False, summarize=True)[source][source]¶ Run backprop for
iter
iterationsParameters: - iter – number of iterations to run
- mini_batch_size – Size of the mini batch to process with
- training_accuracy – if
True
, will calculate accuracy on training data also. - update_after_iter – This is the iteration for validation
- summarize – Tensorboard operation