A Layered Recurrent Neural Network for Feature Grouping