mirror of
https://github.com/sjwhitworth/golearn.git
synced 2025-04-28 13:48:56 +08:00
Merge pull request #120 from EtienneBruines/master
Updated Dot and Sum methods according to changes in gonum/matrix.
This commit is contained in:
commit
6ed783530a
@ -14,7 +14,7 @@ func NewEuclidean() *Euclidean {
|
|||||||
|
|
||||||
// InnerProduct computes a Eucledian inner product.
|
// InnerProduct computes a Eucledian inner product.
|
||||||
func (e *Euclidean) InnerProduct(vectorX *mat64.Dense, vectorY *mat64.Dense) float64 {
|
func (e *Euclidean) InnerProduct(vectorX *mat64.Dense, vectorY *mat64.Dense) float64 {
|
||||||
result := vectorX.Dot(vectorY)
|
result := mat64.Dot(vectorX, vectorY)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ func NewPolyKernel(degree int) *PolyKernel {
|
|||||||
// InnerProduct computes the inner product through a kernel trick
|
// InnerProduct computes the inner product through a kernel trick
|
||||||
// K(x, y) = (x^T y + 1)^d
|
// K(x, y) = (x^T y + 1)^d
|
||||||
func (p *PolyKernel) InnerProduct(vectorX *mat64.Dense, vectorY *mat64.Dense) float64 {
|
func (p *PolyKernel) InnerProduct(vectorX *mat64.Dense, vectorY *mat64.Dense) float64 {
|
||||||
result := vectorX.Dot(vectorY)
|
result := mat64.Dot(vectorX, vectorY)
|
||||||
result = math.Pow(result+1, float64(p.degree))
|
result = math.Pow(result+1, float64(p.degree))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -322,7 +322,7 @@ func (m *MultiLayerNet) Fit(X base.FixedDataGrid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update total error
|
// Update total error
|
||||||
totalError += math.Abs(errVec.Sum())
|
totalError += math.Abs(mat64.Sum(errVec))
|
||||||
|
|
||||||
// Back-propagate the error
|
// Back-propagate the error
|
||||||
b := m.network.Error(trainVec, errVec, totalLayers)
|
b := m.network.Error(trainVec, errVec, totalLayers)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user