It's also useful to have visualization when we are dealing with image data. Earlier we had converted our image pixels from a byte to a float64 using pixelWeight. It'd be instructive to also have the reverse function:
func reversePixelWeight(px float64) byte { return byte(((px - 0.001) / 0.999) * pixelRange)}
Here's how to visualize 100 of the images:
// visualize visualizes the first N images given a data tensor that is made up of float64s.// It's arranged into (rows, 10) image.// Row counts are calculated by dividing N by 10 - we only ever want 10 columns.// For simplicity's sake, we will truncate any remainders.func visualize(data tensor.Tensor, rows, cols int, filename string) (err error) { N := rows * cols sliced := data ...