本文整理汇总了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
}