Last active
November 8, 2016 09:52
-
-
Save MattChanTK/21552868f533a2afbc4a5b4c18abce9e 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
| ''' | |
| ---------------------- | |
| Setting up the trainer | |
| ---------------------- | |
| ''' | |
| # Define the label as the other input parameter of the trainer | |
| labels = cntk.ops.input_variable(output_dim, np.float32) | |
| #Initialize the parameters for the trainer | |
| train_minibatch_size = 50 | |
| learning_rate = 1e-4 | |
| momentum = 0.9 | |
| # Define the loss function | |
| loss = cntk.ops.cross_entropy_with_softmax(output, labels) | |
| # Define the function that calculates classification error | |
| label_error = cntk.ops.classification_error(output, labels) | |
| # Instantiate the trainer object to drive the model training | |
| learner = cntk.adam_sgd(output.parameters, learning_rate, momentum) | |
| trainer = cntk.Trainer(output, loss, label_error, [learner]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment