Representation Learning for Open Set Recognition and Novel Category Discovery