Last active
November 7, 2016 08:54
-
-
Save MattChanTK/35d0963a92828e13bdb7f82b56b16f1d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| ----------------------------------------- | |
| Training the Convolutional Neural Network | |
| ----------------------------------------- | |
| ''' | |
| num_training_epoch = 1 | |
| training_progress_output_freq = 10 | |
| for epoch in range(num_training_epoch): | |
| sample_count = 0 | |
| num_minibatch = 0 | |
| # loop over minibatches in the epoch | |
| while sample_count < num_train_samples: | |
| minibatch = train_minibatch_source.next_minibatch(min(train_minibatch_size, num_train_samples - sample_count)) | |
| # Specify the mapping of input variables in the model to actual minibatch data to be trained with | |
| data = {input_vars: minibatch[training_features], | |
| labels: minibatch[training_labels]} | |
| trainer.train_minibatch(data) | |
| sample_count += data[labels].num_samples | |
| num_minibatch += 1 | |
| # Print the training progress data | |
| if num_minibatch % training_progress_output_freq == 0: | |
| training_loss = cntk.get_train_loss(trainer) | |
| eval_error = cntk.get_train_eval_criterion(trainer) | |
| print("Epoch %d | # of Samples: %6d | Loss: %.6f | Error: %.6f" % (epoch, sample_count, training_loss, eval_error)) | |
| print("Training Completed.", end="\n\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment