Combine AlphaGo's policy, value, and L2 objectives. For batch size B, action count A, target search policy π, and probabilities p given by softmax of policy_logits across actions, compute
ℓp=−B1i=1∑Ba=1∑Aπi,alogpi,a.Here i indexes batch items, a indexes actions, and ℓp is policy loss. For predicted_values v and target_values z, the value loss is
ℓv=B1i=1∑B(vi−zi)2.For parameter tensor θj at index j in parameters and l2_coefficient λ, the regularization loss is
ℓr=λj∑∥θj∥22.The total loss is
ℓ=ℓp+ℓv+ℓr.Return a four-item tuple of scalar PyTorch float32 tensors in this order: total loss, policy loss, value loss, regularization loss. Keep them on the input device; an empty parameter list contributes zero regularization.
Input: policy_logits = [[0,0]], predicted_values = [0], target_policies = [[1,0]], target_values = [1], parameters = [[1,-1]], l2_coefficient = 0.1
Output: (1.893147, 0.693147, 1, 0.2)
Explanation: The total adds log(2), unit value error, and the weighted squared parameter norm.
Input: policy_logits = [[2,-1,0.5],[-2,3,0]], predicted_values = [0.4,-0.2], target_policies = [[0.6,0.1,0.3],[0.2,0.5,0.3]], target_values = [0.5,-0.5], parameters = [], l2_coefficient = 0
Output: (1.523148, 1.473148, 0.05, 0)
Input: policy_logits = [[1000,999],[-1000,-999]], predicted_values = [1,-1], target_policies = [[0.25,0.75],[0.8,0.2]], target_values = [1,-1], parameters = [[0.5],[2,-3]], l2_coefficient = 0.01
Output: (1.220762, 1.088262, 0, 0.1325)
torch.log_softmax provides stable log probabilities across actions.
torch.square and torch.sum give a parameter tensor's squared norm.
Tensor.new_zeros can create a scalar on the input device and dtype.
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: number
Combine AlphaGo's policy, value, and L2 objectives. For batch size B, action count A, target search policy π, and probabilities p given by softmax of policy_logits across actions, compute
ℓp=−B1i=1∑Ba=1∑Aπi,alogpi,a.Here i indexes batch items, a indexes actions, and ℓp is policy loss. For predicted_values v and target_values z, the value loss is
ℓv=B1i=1∑B(vi−zi)2.For parameter tensor θj at index j in parameters and l2_coefficient λ, the regularization loss is
ℓr=λj∑∥θj∥22.The total loss is
ℓ=ℓp+ℓv+ℓr.Return a four-item tuple of scalar PyTorch float32 tensors in this order: total loss, policy loss, value loss, regularization loss. Keep them on the input device; an empty parameter list contributes zero regularization.
Input: policy_logits = [[0,0]], predicted_values = [0], target_policies = [[1,0]], target_values = [1], parameters = [[1,-1]], l2_coefficient = 0.1
Output: (1.893147, 0.693147, 1, 0.2)
Explanation: The total adds log(2), unit value error, and the weighted squared parameter norm.
Input: policy_logits = [[2,-1,0.5],[-2,3,0]], predicted_values = [0.4,-0.2], target_policies = [[0.6,0.1,0.3],[0.2,0.5,0.3]], target_values = [0.5,-0.5], parameters = [], l2_coefficient = 0
Output: (1.523148, 1.473148, 0.05, 0)
Input: policy_logits = [[1000,999],[-1000,-999]], predicted_values = [1,-1], target_policies = [[0.25,0.75],[0.8,0.2]], target_values = [1,-1], parameters = [[0.5],[2,-3]], l2_coefficient = 0.01
Output: (1.220762, 1.088262, 0, 0.1325)
torch.log_softmax provides stable log probabilities across actions.
torch.square and torch.sum give a parameter tensor's squared norm.
Tensor.new_zeros can create a scalar on the input device and dtype.
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: number