Hierarchial training and classification