Nonequilibrium phase transitions in pattern recognition and associative memory