function W = simple_mlp_vec2cell(vec, dims, rmaj)
% For unwrapping the weights. Order of vec: b1 W1colMaj b2 W2colMaj ...


rowmajor = (nargin==3) && ischar(rmaj) && strcmp(rmaj, 'row');

ind=0;
for L = 1:numel(dims)-1
  sz = (dims(L)+1)*dims(L+1);
  ia = ind+1;
  ib = ind+sz;
  
if rowmajor
  W{L} = reshape(vec(ia:ib), dims(L)+1, dims(L+1))';
else % ..it is column major (default)
  W{L} = reshape(vec(ia:ib),dims(L+1), dims(L)+1);
end

  ind = ib;
end
