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


Golang autofunc.Result类代码示例

本文整理汇总了Golang中github.com/unixpickle/autofunc.Result的典型用法代码示例。如果您正苦于以下问题:Golang Result类的具体用法?Golang Result怎么用?Golang Result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Result类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Apply

func (u *UnstackLayer) Apply(in autofunc.Result) autofunc.Result {
	return &unstackLayerResult{
		OutputVector: u.unstack(in.Output()),
		Input:        in,
		Layer:        u,
	}
}
开发者ID:unixpickle,项目名称:weakai,代码行数:7,代码来源:unstack_layer.go

示例2: Apply

func (b *BorderLayer) Apply(in autofunc.Result) autofunc.Result {
	return &borderResult{
		OutputVec: b.addBorder(in.Output()),
		Input:     in,
		Info:      b,
	}
}
开发者ID:unixpickle,项目名称:weakai,代码行数:7,代码来源:border_layer.go

示例3: Apply

func (d *DropoutLayer) Apply(in autofunc.Result) autofunc.Result {
	if d.Training {
		return autofunc.Mul(in, d.dropoutMask(len(in.Output())))
	} else {
		return autofunc.Scale(in, d.KeepProbability)
	}
}
开发者ID:unixpickle,项目名称:weakai,代码行数:7,代码来源:dropout.go

示例4: Apply

func (g *GaussNoiseLayer) Apply(in autofunc.Result) autofunc.Result {
	if g.Training {
		return autofunc.Add(in, g.noise(len(in.Output())))
	} else {
		return in
	}
}
开发者ID:unixpickle,项目名称:weakai,代码行数:7,代码来源:gauss_noise.go

示例5: networkOutput

func networkOutput(r autofunc.Result) int {
	out := r.Output()
	var maxIdx int
	var max float64
	for i, x := range out {
		if i == 0 || x > max {
			max = x
			maxIdx = i
		}
	}
	return maxIdx
}
开发者ID:unixpickle,项目名称:weakai,代码行数:12,代码来源:main.go

示例6: Apply

func (_ ReLU) Apply(r autofunc.Result) autofunc.Result {
	inVec := r.Output()
	vec := make(linalg.Vector, len(inVec))
	for i, x := range inVec {
		if x > 0 {
			vec[i] = x
		}
	}
	return &reLUResult{
		OutputVec: vec,
		Input:     r,
	}
}
开发者ID:unixpickle,项目名称:weakai,代码行数:13,代码来源:activation_func.go

示例7: Apply

func (s *LogSoftmaxLayer) Apply(in autofunc.Result) autofunc.Result {
	return autofunc.Pool(in, func(in autofunc.Result) autofunc.Result {
		// Compute the log of the sum of the exponents by
		// factoring out the largest exponent so that all
		// the exponentials fit nicely inside floats.
		maxIdx := maxVecIdx(in.Output())
		maxValue := autofunc.Slice(in, maxIdx, maxIdx+1)
		exponents := autofunc.AddFirst(in, autofunc.Scale(maxValue, -1))
		expSum := autofunc.SumAll(autofunc.Exp{}.Apply(exponents))
		expLog := autofunc.Log{}.Apply(expSum)
		denomLog := autofunc.Add(expLog, maxValue)
		return autofunc.AddFirst(in, autofunc.Scale(denomLog, -1))
	})
}
开发者ID:unixpickle,项目名称:weakai,代码行数:14,代码来源:softmax_layer.go

示例8: Batch

// Batch applies the layer to inputs in batch.
func (m *MaxPoolingLayer) Batch(in autofunc.Result, n int) autofunc.Result {
	outSize := m.OutputWidth() * m.OutputHeight() * m.InputDepth
	inSize := m.InputWidth * m.InputHeight * m.InputDepth
	if len(in.Output()) != n*inSize {
		panic("invalid input size")
	}
	res := &maxPoolingResult{
		OutputVec: make(linalg.Vector, outSize*n),
		Input:     in,
		Layer:     m,
	}
	for i := 0; i < n; i++ {
		outTensor := m.outputTensor(res.OutputVec[i*outSize : (i+1)*outSize])
		inTensor := m.inputTensor(in.Output()[i*inSize : (i+1)*inSize])
		choices := m.evaluate(inTensor, outTensor)
		res.Choices = append(res.Choices, choices)
	}
	return res
}
开发者ID:unixpickle,项目名称:weakai,代码行数:20,代码来源:max_pooling_layer.go

示例9: Batch

func (l *lstmGate) Batch(in autofunc.Result, n int) autofunc.Result {
	if l.Peephole == nil {
		return l.Activation.Apply(l.Dense.Batch(in, n))
	}
	return autofunc.Pool(in, func(in autofunc.Result) autofunc.Result {
		vecSize := len(in.Output()) / n
		var weightedInputs []autofunc.Result
		var peepholed []autofunc.Result
		for i := 0; i < n; i++ {
			start := vecSize * i
			weightedEnd := start + vecSize - len(l.Peephole.Vector)
			weightedInputs = append(weightedInputs, autofunc.Slice(in, start, weightedEnd))
			peepholeMe := autofunc.Slice(in, weightedEnd, (i+1)*vecSize)
			peepholed = append(peepholed, autofunc.Mul(l.Peephole, peepholeMe))
		}
		weighted := l.Dense.Batch(autofunc.Concat(weightedInputs...), n)
		return l.Activation.Apply(autofunc.Add(autofunc.Concat(peepholed...), weighted))
	})
}
开发者ID:unixpickle,项目名称:weakai,代码行数:19,代码来源:lstm.go

示例10: Batch

// Batch applies the layer to inputs in batch.
func (c *ConvLayer) Batch(in autofunc.Result, n int) autofunc.Result {
	if c.Filters == nil || c.Biases == nil || c.FilterVar == nil {
		panic(uninitPanicMessage)
	}
	outSize := c.OutputWidth() * c.OutputHeight() * c.OutputDepth()
	inSize := c.InputWidth * c.InputHeight * c.InputDepth
	if len(in.Output()) != n*inSize {
		panic("invalid input size")
	}
	res := &convLayerResult{
		OutputVec: make(linalg.Vector, outSize*n),
		Input:     in,
		N:         n,
		Layer:     c,
	}
	for i := 0; i < n; i++ {
		subIn := in.Output()[i*inSize : (i+1)*inSize]
		subOut := res.OutputVec[i*outSize : (i+1)*outSize]
		c.convolve(subIn, c.outputToTensor(subOut))
	}
	return res
}
开发者ID:unixpickle,项目名称:weakai,代码行数:23,代码来源:conv_layer.go


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