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


Golang Matrix.GetMRows方法代碼示例

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


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

示例1: ForwardPropagation

//TODO the activation function and his Derviate has to be more general.. to implemente soft-max for example
func (this *ANN) ForwardPropagation(In *Matrix.Matrix) (As, AsDerviate *([]*Matrix.Matrix), Output *Matrix.Matrix) {
	if In.GetMRows() == this.Inputs && In.GetNColumns() == 1 {
		As1 := make([]*Matrix.Matrix, len(this.Weights)+1, len(this.Weights)+1)
		AsDerviate1 := make([]*Matrix.Matrix, len(this.Weights)+1, len(this.Weights)+1)

		As := &As1
		AsDerviate = &AsDerviate1

		sTemp := In.Transpose()

		//Add  a new column for a Bias Weight
		sTemp = sTemp.AddColumn(Matrix.I(1))

		holeInput := sTemp.Copy()
		As1[0] = sTemp.Transpose()

		//Derivate
		//sutract, _ := Matrix.Sustract(Matrix.OnesMatrix(As1[0].GetMRows(), 1), As1[0])
		//derivate := Matrix.DotMultiplication(As1[0], sutract)

		//derivate := holeInput.Apply(this.Derivate)
		derivate := this.DarivateActivationLayer(holeInput)

		AsDerviate1[0] = derivate.Transpose()

		for i := 0; i < len(this.Weights); i++ {
			sTemp = Matrix.Product(sTemp, (this.Weights[i]))

			//apply the activation functions
			holeInput := sTemp.Copy()
			sTemp = this.ActivationLayer(sTemp)

			//sTemp = sTemp.Apply(this.Activation)

			//Add  a new column for a Bias Weight
			sTemp = sTemp.AddColumn(Matrix.I(1))
			(*As)[i+1] = sTemp.Transpose()

			//Derivate
			//sutract, _ := Matrix.Sustract(Matrix.OnesMatrix((*As)[i+1].GetMRows(), 1), (*As)[i+1])
			//derivate := Matrix.DotMultiplication((*As)[i+1], sutract)

			derivate := this.DarivateActivationLayer(holeInput)
			//derivate := holeInput.Apply(this.Derivate)

			(*AsDerviate)[i+1] = derivate.Transpose()

		}
		Asf := sTemp.Copy()

		//Asf = Asf.AddColumn(Matrix.I(1))
		(*As)[len(As1)-1] = Asf.Transpose()
		Output = sTemp.Transpose().MatrixWithoutLastRow()
		return As, AsDerviate, Output
	}
	return nil, nil, nil
}
開發者ID:eddytrex,項目名稱:AIgo,代碼行數:58,代碼來源:ANN.go

示例2: MakeTrainingSet

func MakeTrainingSet(xs *Matrix.Matrix, y *Matrix.Matrix) *TrainingSet {
	var out TrainingSet

	if xs.GetMRows() == y.GetMRows() {
		out.Xs = xs
		out.Y = y
		return &out
	}
	return nil
}
開發者ID:eddytrex,項目名稱:AIgo,代碼行數:10,代碼來源:TrainningSet.go

示例3: FFT

func FFT(this *Matrix.Matrix, N int) (*Matrix.Matrix, error) {
	if N > this.GetMRows() {
		return nil, errors.New(" The number of Rows of the matrix (this) must be greater or equal than N ")
	}
	if N&(N-1) == 0 {
		tf := TwiddleFactors(N, false)

		Xr := FFT_ct3(this, N, 1, &tf)

		return Xr, nil
	}
	return nil, errors.New(" The N parameter has to be power of 2")
}
開發者ID:eddytrex,項目名稱:AIgo,代碼行數:13,代碼來源:DFT.go

示例4: IFFT

func IFFT(this *Matrix.Matrix, N int) (*Matrix.Matrix, error) {
	if N > this.GetMRows() {
		return nil, errors.New(" The number of Rows of the matrix (this) must be greater or equal than N ")
	}
	if N&(N-1) == 0 {
		tf := TwiddleFactors(N, true)

		Xr := FFT_ct(this, N, 1, &tf)

		Xr = Xr.Scalar(complex(float64(1)/float64(N), 0))
		return Xr, nil
	}
	return nil, errors.New(" The N parameter has to be power of 2")
}
開發者ID:eddytrex,項目名稱:AIgo,代碼行數:14,代碼來源:DFT.go


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