本文整理汇总了Golang中github.com/xlvector/hector/core.Vector.GetValue方法的典型用法代码示例。如果您正苦于以下问题:Golang Vector.GetValue方法的具体用法?Golang Vector.GetValue怎么用?Golang Vector.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/xlvector/hector/core.Vector
的用法示例。
在下文中一共展示了Vector.GetValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getScore
func (lr *LROWLQN) getScore(model *core.Vector, sample *core.Sample) float64 {
var score float64 = 0
for _, fea := range sample.Features {
score += model.GetValue(fea.Id) * fea.Value
}
return score
}
示例2: 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)
}
}
}
示例3: Cov
func (cov_func *CovSEARD) Cov(x1 *core.Vector, x2 *core.Vector) float64 {
ret := 0.0
tmp := 0.0
for key, r := range cov_func.Radiuses.Data {
v1 := x1.GetValue(key)
v2 := x2.GetValue(key)
tmp = (v1 - v2) / r
ret += tmp * tmp
}
ret = cov_func.Amp * math.Exp(-ret)
return ret
}
示例4: Equals
func (lr *LROWLQN) Equals(x *core.Vector, y *core.Vector) bool {
if y == nil && x == nil {
return true
}
if y == nil || x == nil {
return false
}
for key, val := range x.Data {
if y.GetValue(key) != val {
return false
}
}
for key, val := range y.Data {
if x.GetValue(key) != val {
return false
}
}
return true
}
示例5: 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
}
示例6: 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
}