main.py
def optimize(nn_last_layer, correct_label, learning_rate, num_classes):
    """
    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)
    """
    
    #Re-shape output and label tensors to 2-D
    logits = tf.reshape(nn_last_layer, (-1, num_classes))
    correct_label = tf.reshape(correct_label, (-1,num_classes))
        
    #Loss Function (include regularization losses here)
    cross_entropy_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits( \
                                         logits= logits, labels= correct_label))    
    cross_entropy_loss = cross_entropy_loss + tf.losses.get_regularization_loss()
    
    #Training using AdamOptimizer
    optimizer = tf.train.AdamOptimizer(learning_rate = learning_rate)
    train_op = optimizer.minimize(cross_entropy_loss)
    
    return logits,train_op,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)
    
Build the TensorFLow loss and optimizer operations.
Build the TensorFLow loss and optimizer operations .
def optimize(nn_last_layer, correct_label, learning_rate, num_classes):
    logits = tf.reshape(nn_last_layer, (-1, num_classes))
    correct_label = tf.reshape(correct_label, (-1,num_classes))
    cross_entropy_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits( \
                                         logits= logits, labels= correct_label))    
    cross_entropy_loss = cross_entropy_loss + tf.losses.get_regularization_loss()
    optimizer = tf.train.AdamOptimizer(learning_rate = learning_rate)
    train_op = optimizer.minimize(cross_entropy_loss)
    return logits,train_op,cross_entropy_loss
def optimize ( nn_last_layer , correct_label , learning_rate , num_classes ) : logits = tf . reshape ( nn_last_layer , ( - 1 , num_classes ) ) correct_label = tf . reshape ( correct_label , ( - 1 , num_classes ) ) cross_entropy_loss = tf . reduce_mean ( tf . nn . softmax_cross_entropy_with_logits ( logits = logits , labels = correct_label ) ) cross_entropy_loss = cross_entropy_loss + tf . losses . get_regularization_loss ( ) optimizer = tf . train . AdamOptimizer ( learning_rate = learning_rate ) train_op = optimizer . minimize ( cross_entropy_loss ) return logits , train_op , cross_entropy_loss
Build the TensorFLow loss and optimizer operations.
Build the TensorFLow loss and optimizer operations .
"""
    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)
    """ #Re-shape output and label tensors to 2-D #Loss Function (include regularization losses here) #Training using AdamOptimizer
Tuple of (logits, train_op, cross_entropy_loss)
Tuple of ( logits train_op cross_entropy_loss )
nn_last_layer
TF Tensor of the last layer in the neural network
TF Tensor of the last layer in the neural network
correct_label
TF Placeholder for the correct label image
TF Placeholder for the correct label image
learning_rate
TF Placeholder for the learning rate
TF Placeholder for the learning rate
num_classes
Number of classes to classify
Number of classes to classify