(model, softmax, label)
Adds training operators to the model.
Adds training operators to the model.
Adds training operators to the model .
def AddTrainingOperators(model, softmax, label):
    """Adds training operators to the model."""
    # Compute cross entropy between softmax scores and labels
    xent = model.LabelCrossEntropy([softmax, label], 'xent')
    # Compute the expected loss
    loss = model.AveragedLoss(xent, "loss")
    # Track the accuracy of the model
    AddAccuracy(model, softmax, label)
    # Use the average loss we just computed to add gradient operators to the model
    model.AddGradientOperators([loss])
    # Specify the optimization algorithm
    optimizer.build_sgd(
        model,
        base_learning_rate=0.1,
        policy="step",
        stepsize=1,
        gamma=0.999,
    )
def AddTrainingOperators ( model , softmax , label ) : # Compute cross entropy between softmax scores and labels xent = model . LabelCrossEntropy ( [ softmax , label ] , 'xent' ) # Compute the expected loss loss = model . AveragedLoss ( xent , "loss" ) # Track the accuracy of the model AddAccuracy ( model , softmax , label ) # Use the average loss we just computed to add gradient operators to the model model . AddGradientOperators ( [ loss ] ) # Specify the optimization algorithm optimizer . build_sgd ( model , base_learning_rate = 0.1 , policy = "step" , stepsize = 1 , gamma = 0.999 , )