Exemple #1
0
func main() {
	normalize(xTrain, mat64.Max(xTrain))
	// max test score is 100
	normalize(yTrain, 100)
	yHat := forward(xTrain)
	cost := cost(yTrain, &yHat)
	denormalize(&yHat, 100)
	fmt.Println(yHat)
	fmt.Println(cost)
}
Exemple #2
0
func TestCost(t *testing.T) {
	var xTrain *mat64.Dense = mat64.NewDense(3, 2, []float64{3, 5, 5, 1, 10, 2})
	var yTrain *mat64.Dense = mat64.NewDense(3, 1, []float64{75, 82, 93})
	var expectedCost float64 = 0.011186939034305027

	normalize(xTrain, mat64.Max(xTrain))
	// max test score is 100
	normalize(yTrain, 100)
	yHat := forward(xTrain)
	cost := cost(yTrain, &yHat)

	if cost != expectedCost {
		t.Error()
	}

}