Metric
Metric computes distance metrics for comparing tensors. The different metrics supported are: stats/metric.Metrics.
##
x := rand(12)
y := rand(12)
l2 := metric.L2Norm(x, y)
r := metric.Correlation(x, y)
fmt.Println("x:", x)
fmt.Println("y:", y)
fmt.Println("l2:", l2)
fmt.Println("r:", r)
## As with statistics, n-dimensional data is treated in a row-based manner, computing a metric value over the data across rows:
##
x := rand(12).reshape(3,4)
y := rand(12).reshape(3,4)
l2 := metric.L2Norm(x, y)
r := metric.Correlation(x, y)
fmt.Println("x:", x)
fmt.Println("y:", y)
fmt.Println("l2:", l2)
fmt.Println("r:", r)
##To get a single value for each row representing the metric computed on the elements within that row, you need to iterate and slice:
##
x := rand(12).reshape(3,4)
y := rand(12).reshape(3,4)
l2 := zeros(3)
for i := range l2 {
l2[i] = metric.L2Norm(x[i], y[i])
}
fmt.Println("x:", x)
fmt.Println("y:", y)
fmt.Println("l2:", l2)
##