Learning the Dimensionality of Hidden Variables