Fix invalid accesses.
Fix invalid accesses.

ajjl/mlpack,darcyliu/mlpack,darcyliu/mlpack,palashahuja/mlpack,ajjl/mlpack,ranjan1990/mlpack,palashahuja/mlpack,ranjan1990/mlpack,palashahuja/mlpack,ranjan1990/mlpack,darcyliu/mlpack,ajjl/mlpack