Fault-tolerance of optical and electronic Hebbian-type associative memories