本文整理匯總了Golang中github.com/xlvector/hector/core.Vector.SetValue方法的典型用法代碼示例。如果您正苦於以下問題:Golang Vector.SetValue方法的具體用法?Golang Vector.SetValue怎麽用?Golang Vector.SetValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/xlvector/hector/core.Vector
的用法示例。
在下文中一共展示了Vector.SetValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: fixDirSign
func (m *OWLQNMinimizer) fixDirSign(dir *core.Vector, steepestDescDir *core.Vector) {
if m.l1reg == 0 {
return
}
for key, val := range dir.Data {
if val*steepestDescDir.GetValue(key) <= 0 {
dir.SetValue(key, 0)
}
}
}
示例2: updateGrad
// Description: assume all the features in x also appears in grad
func (m *OWLQNMinimizer) updateGrad(x *core.Vector, grad *core.Vector) {
if m.l1reg == 0 {
return
}
for key, val := range grad.Data {
xval := x.GetValue(key)
if xval < 0 {
grad.SetValue(key, val-m.l1reg)
} else if xval > 0 {
grad.SetValue(key, val+m.l1reg)
} else {
if val < -m.l1reg {
grad.SetValue(key, val+m.l1reg)
} else if val > m.l1reg {
grad.SetValue(key, val-m.l1reg)
}
}
}
return
}
示例3: updateGradForNewPos
// Description: assume all the features in x also appears in grad
// all the features in dir must be in grad
func (m *OWLQNMinimizer) updateGradForNewPos(x *core.Vector, grad *core.Vector, dir *core.Vector) {
if m.l1reg == 0 {
return
}
for key, val := range grad.Data {
xval := x.GetValue(key)
if xval < 0 {
grad.SetValue(key, val-m.l1reg)
} else if xval > 0 {
grad.SetValue(key, val+m.l1reg)
} else {
dirval := dir.GetValue(key)
if dirval < 0 {
grad.SetValue(key, val-m.l1reg)
} else if dirval > 0 {
grad.SetValue(key, val+m.l1reg)
}
}
}
return
}