本文整理匯總了Golang中github.com/unixpickle/num-analysis/linalg.Vector.Copy方法的典型用法代碼示例。如果您正苦於以下問題:Golang Vector.Copy方法的具體用法?Golang Vector.Copy怎麽用?Golang Vector.Copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/unixpickle/num-analysis/linalg.Vector
的用法示例。
在下文中一共展示了Vector.Copy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Loss
// Loss returns the weighted exponential loss.
// It determines which samples are positive vs. negative
// by checking the sign of the element in the expected
// vector.
func (w *WeightedExpLoss) Loss(actual autofunc.Result, expected linalg.Vector) autofunc.Result {
expVar := &autofunc.Variable{Vector: expected.Copy().Scale(-1)}
dots := autofunc.Mul(actual, expVar)
exps := autofunc.Exp{}.Apply(dots)
weightVec := &autofunc.Variable{Vector: make(linalg.Vector, len(expected))}
for i, x := range expected {
if x > 0 {
weightVec.Vector[i] = w.PosWeight
} else {
weightVec.Vector[i] = 1
}
}
return autofunc.SumAll(autofunc.Mul(exps, weightVec))
}
示例2: CostR
func (_ MeanSquaredCost) CostR(v autofunc.RVector, a linalg.Vector,
x autofunc.RResult) autofunc.RResult {
aVar := &autofunc.Variable{a.Copy().Scale(-1)}
aVarR := autofunc.NewRVariable(aVar, v)
return autofunc.SquaredNorm{}.ApplyR(v, autofunc.AddR(aVarR, x))
}