Torch Tutorial: meaning of "trainData.data[{ {},i,{},{} }]:mean()" in 1_data.lua -


in torch tutorial, found line:

mean[i] = traindata.data[{ {},i,{},{} }]:mean() 

is there can explain indexing { {},i,{},{} } doing? guess, wanted know exact mechanism.

thanks in advance.

this concise syntax tensor narrowing / slicing, detailed here in documentation.

inside [{ ... }], can each dimension of tensor:

  • pass number n keep n-th component along dimension,
  • pass range {start,end} keep components start end along dimension,
  • pass {} keep components along dimension.

in precise case, it's narrowing u * v * w * x tensor u * 1 * w * x tensor keeping i-th component along 2nd dimension.


Comments