當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。