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
nkeepn-th component along dimension, - pass range
{start,end}keep componentsstartendalong 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
Post a Comment