Deep learning to make nanoscale designs more robust against defects