A new way to train AI systems could keep them safer from hackers