當前位置: 首頁>>代碼示例>>Golang>>正文


Golang RResult.ROutput方法代碼示例

本文整理匯總了Golang中github.com/unixpickle/autofunc.RResult.ROutput方法的典型用法代碼示例。如果您正苦於以下問題:Golang RResult.ROutput方法的具體用法?Golang RResult.ROutput怎麽用?Golang RResult.ROutput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/unixpickle/autofunc.RResult的用法示例。


在下文中一共展示了RResult.ROutput方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: BatchR

// BatchR is like Batch, but for RResults.
func (c *ConvLayer) BatchR(rv autofunc.RVector, in autofunc.RResult,
	n int) autofunc.RResult {
	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 := &convLayerRResult{
		OutputVec:  make(linalg.Vector, outSize*n),
		ROutputVec: make(linalg.Vector, outSize*n),
		Input:      in,
		FiltersR:   rv[c.FilterVar],
		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))

		subInR := in.ROutput()[i*inSize : (i+1)*inSize]
		subOutR := res.ROutputVec[i*outSize : (i+1)*outSize]
		c.convolveR(rv, subIn, subInR, c.outputToTensor(subOutR))
	}
	return res
}
開發者ID:unixpickle,項目名稱:weakai,代碼行數:30,代碼來源:conv_layer.go

示例2: manualNetworkSeq

func manualNetworkSeq(rv autofunc.RVector, f autofunc.RFunc, start *autofunc.Variable,
	ins [][]*autofunc.Variable, stateSize int) (out, outR [][]linalg.Vector) {
	out = make([][]linalg.Vector, len(ins))
	outR = make([][]linalg.Vector, len(ins))
	for seqIdx, inSeq := range ins {
		var state autofunc.RResult = autofunc.NewRVariable(start, rv)
		for _, in := range inSeq {
			inR := rv[in]

			packedIn := append(linalg.Vector{}, in.Output()...)
			packedIn = append(packedIn, state.Output()...)
			packedInR := append(linalg.Vector{}, inR...)
			packedInR = append(packedInR, state.ROutput()...)

			stepOut := f.ApplyR(rv, &autofunc.RVariable{
				Variable:   &autofunc.Variable{Vector: packedIn},
				ROutputVec: packedInR,
			})
			outSize := len(stepOut.Output()) - stateSize
			out[seqIdx] = append(out[seqIdx], stepOut.Output()[:outSize])
			outR[seqIdx] = append(outR[seqIdx], stepOut.ROutput()[:outSize])
			state = &autofunc.RVariable{
				Variable:   &autofunc.Variable{Vector: stepOut.Output()[outSize:]},
				ROutputVec: stepOut.ROutput()[outSize:],
			}
		}
	}
	return
}
開發者ID:unixpickle,項目名稱:weakai,代碼行數:29,代碼來源:baseline_test.go

示例3: BatchR

// BatchR is like Batch, but for RResults.
func (m *MaxPoolingLayer) BatchR(rv autofunc.RVector, in autofunc.RResult,
	n int) autofunc.RResult {
	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 := &maxPoolingRResult{
		OutputVec:  make(linalg.Vector, outSize*n),
		ROutputVec: 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)

		outTensorR := m.outputTensor(res.ROutputVec[i*outSize : (i+1)*outSize])
		inTensorR := m.inputTensor(in.ROutput()[i*inSize : (i+1)*inSize])
		choices.ForwardPropagate(inTensorR, outTensorR)
	}
	return res
}
開發者ID:unixpickle,項目名稱:weakai,代碼行數:26,代碼來源:max_pooling_layer.go

示例4: ApplyR

func (u *UnstackLayer) ApplyR(v autofunc.RVector, in autofunc.RResult) autofunc.RResult {
	return &unstackLayerRResult{
		OutputVector:  u.unstack(in.Output()),
		ROutputVector: u.unstack(in.ROutput()),
		Input:         in,
		Layer:         u,
	}
}
開發者ID:unixpickle,項目名稱:weakai,代碼行數:8,代碼來源:unstack_layer.go

示例5: ApplyR

func (b *BorderLayer) ApplyR(rv autofunc.RVector, in autofunc.RResult) autofunc.RResult {
	return &borderRResult{
		OutputVec:  b.addBorder(in.Output()),
		ROutputVec: b.addBorder(in.ROutput()),
		Input:      in,
		Info:       b,
	}
}
開發者ID:unixpickle,項目名稱:weakai,代碼行數:8,代碼來源:border_layer.go

示例6: ApplyR

func (_ ReLU) ApplyR(v autofunc.RVector, r autofunc.RResult) autofunc.RResult {
	outVec := r.Output()
	outVecR := r.ROutput()
	vec := make(linalg.Vector, len(outVec))
	vecR := make(linalg.Vector, len(outVec))
	for i, x := range outVec {
		if x > 0 {
			vec[i] = x
			vecR[i] = outVecR[i]
		}
	}
	return &reLURResult{
		OutputVec:  vec,
		ROutputVec: vecR,
		Input:      r,
	}
}
開發者ID:unixpickle,項目名稱:weakai,代碼行數:17,代碼來源:activation_func.go


注:本文中的github.com/unixpickle/autofunc.RResult.ROutput方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。