We approach the problem of identifying facies from well logs through the use of neural networks that perform vector quantization of input data by competitive learning. The method can be used in either an unsupervised or supervised manner. Unsupervised analysis is used to segregate a well into distinct facies classes based on the log behavior. Supervised analysis is used to identify the facies types present in a certain well by making use of the facies identified from cores in a nearby well. The method is suitable for analyzing lithologies and depositional facies of horizontal wells, which are almost never cored, especially if core data is available for nearby vertical wells. Both modes are implemented and used for the automatic facies analysis of horizontal wells in Saudi Arabia. In addition to the identification of facies, the method is also able to calculate, for each analysis, confidence measures that are indicative of how well the analysis procedure can identify those facies given uncertainties in the data. Moreover, we can apply constraints derived from human experience and geologic principles to guide the inference process.