I have been trying to use the std
function on a batch of images. For instance, this is a batch of 2 images having 3 channels each -
xs = rand(3, 3, 3, 2)
I want to find the standard deviation of the first image which can be achieved using -
std(xs[:, :, :, 1])
Now I want to achieve the same thing using the dims
kwarg, but I cannot figure out the usage of the same. More precisely, what is the function actually calculating if I pass in a vector as dims? I couldn’t find any examples of this on the internet or in Julia’s documentation. An example with the batch of images defined above -
julia> xs
3×3×3×2 Array{Float64, 4}:
[:, :, 1, 1] =
0.775483 0.804976 0.805342
0.502332 0.571661 0.788025
0.627064 0.175482 0.733361
[:, :, 2, 1] =
0.744905 0.861811 0.236851
0.493482 0.672934 0.954064
0.382317 0.368025 0.0896878
[:, :, 3, 1] =
0.287127 0.505461 0.280565
0.637652 0.07373 0.132018
0.493528 0.173168 0.0917483
[:, :, 1, 2] =
0.993559 0.85186 0.974956
0.962802 0.20569 0.171647
0.344311 0.158447 0.0416952
[:, :, 2, 2] =
0.0756434 0.800149 0.0489549
0.868386 0.197549 0.56844
0.00663242 0.131731 0.614948
[:, :, 3, 2] =
0.154051 0.93772 0.143768
0.196975 0.0213649 0.0269268
0.0658219 0.913233 0.179747
julia> std(xs, dims=[3,1])
1×3×1×2 Array{Float64, 4}:
[:, :, 1, 1] =
0.16137 0.287385 0.354948
[:, :, 1, 2] =
0.412971 0.39161 0.332775
Could someone please explain to me how is the final 1x3x1x2
Array has been calculated? Thank you!