当前位置: 首页>>代码示例>>Golang>>正文


Golang Vector.GetValue方法代码示例

本文整理汇总了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
}
开发者ID:jamesbjackson,项目名称:hector,代码行数:7,代码来源:lr_owlqn.go

示例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)
		}
	}
}
开发者ID:jamesbjackson,项目名称:hector,代码行数:10,代码来源:owlqn_minimizer.go

示例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
}
开发者ID:xzturn,项目名称:hector,代码行数:12,代码来源:covariance_function.go

示例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
}
开发者ID:jamesbjackson,项目名称:hector,代码行数:19,代码来源:lr_owlqn.go

示例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
}
开发者ID:jamesbjackson,项目名称:hector,代码行数:21,代码来源:owlqn_minimizer.go

示例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
}
开发者ID:jamesbjackson,项目名称:hector,代码行数:23,代码来源:owlqn_minimizer.go


注:本文中的github.com/xlvector/hector/core.Vector.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。