Skip to content

Instantly share code, notes, and snippets.

@MattChanTK
Last active November 8, 2016 09:52
Show Gist options
  • Select an option

  • Save MattChanTK/21552868f533a2afbc4a5b4c18abce9e to your computer and use it in GitHub Desktop.

Select an option

Save MattChanTK/21552868f533a2afbc4a5b4c18abce9e to your computer and use it in GitHub Desktop.
'''
----------------------
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