gonum

Multiple line plots sharing abscissas axis in gonum/plot

白昼怎懂夜的黑 提交于 2019-12-14 00:07:25
问题 Is it possible to make multiple line plots with common abscissas axis in gonum/plot? In matplotlib it would look like this. 回答1: Yes, it is possible. You can use plot.Align : package main import ( "math/rand" "os" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/vg" "gonum.org/v1/plot/vg/draw" "gonum.org/v1/plot/vg/vgimg" ) func main() { rand.Seed(int64(0)) const rows, cols = 2, 1 plots := make([][]*plot.Plot, rows) for j := 0; j < rows; j++ { plots[j] = make([]*plot.Plot,

Vectorise a function taking advantage of concurrency

牧云@^-^@ 提交于 2019-12-08 12:15:18
问题 For a simple neural network I want to apply a function to all the values of a gonum VecDense . Gonum has an Apply method for Dense matrices, but not for vectors, so I am doing this by hand: func sigmoid(z float64) float64 { return 1.0 / (1.0 + math.Exp(-z)) } func vSigmoid(zs *mat.VecDense) { for i := 0; i < zs.Len(); i++ { zs.SetVec(i, sigmoid(zs.AtVec(i))) } } This seems to be an obvious target for concurrent execution, so I tried var wg sync.WaitGroup func sigmoid(z float64) float64 { wg