Neural networks for defect detection