def optimize(nn_last_layer, correct_label, learning_rate, num_classes):
    '\n    Build the TensorFLow loss and optimizer operations.\n    :param nn_last_layer: TF Tensor of the last layer in the neural network\n    :param correct_label: TF Placeholder for the correct label image\n    :param learning_rate: TF Placeholder for the learning rate\n    :param num_classes: Number of classes to classify\n    :return: Tuple of (logits, train_op, cross_entropy_loss)\n    '
    logits = tf.reshape(nn_last_layer, ((- 1), num_classes))
    cross_entropy_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=correct_label))
    optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate)
    training_operation = optimizer.minimize(cross_entropy_loss)
    return (logits, training_operation, cross_entropy_loss)
Build the TensorFLow loss and optimizer operations.
:param nn_last_layer: TF Tensor of the last layer in the neural network
:param correct_label: TF Placeholder for the correct label image
:param learning_rate: TF Placeholder for the learning rate
:param num_classes: Number of classes to classify
:return: Tuple of (logits, train_op, cross_entropy_loss)
def optimize(nn_last_layer, correct_label, learning_rate, num_classes):
    '\n    Build the TensorFLow loss and optimizer operations.\n    :param nn_last_layer: TF Tensor of the last layer in the neural network\n    :param correct_label: TF Placeholder for the correct label image\n    :param learning_rate: TF Placeholder for the learning rate\n    :param num_classes: Number of classes to classify\n    :return: Tuple of (logits, train_op, cross_entropy_loss)\n    '
    logits = tf.reshape(nn_last_layer, ((- 1), num_classes))
    cross_entropy_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=correct_label))
    optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate)
    training_operation = optimizer.minimize(cross_entropy_loss)
    return (logits, training_operation, cross_entropy_loss)