A 1D Convolutional Neural Network (1D-CNN) for automated lithology classification from well log data, evaluated using a Leave-One-Well-Out (LOWO) cross-validation scheme. This project was developed as part of an undergraduate thesis focusing on coal seam identification in subsurface formations.
Note: Well log data used in this study is confidential and not included in this repository.
Manual lithology interpretation from well logs is time-consuming and subject to interpreter bias. This project applies deep learning to automate the classification of four lithological classes — Claystone, Sandstone, Coaly Shale, and Coal — using Gamma Ray (GR) and Density (RHOB) logs as input features.
The LOWO scheme ensures that each well is tested as a completely blind well (no data leakage between training and test sets), providing a realistic estimate of model generalization performance across different wells.
| Code | Lithology |
|---|---|
| 0 | Claystone |
| 1 | Sandstone |
| 2 | Coaly Shale |
| 3 | Coal |
- GR — Gamma Ray log
- DENSITY (RHOB) — Bulk density log
Each sample is constructed by extracting a centered window of 101 depth samples around the target depth point. This provides local stratigraphic context for the classifier.
Input: (101, 2)
↓
Conv1D(64, kernel=7, ELU) → BatchNorm → MaxPool(2) → Dropout(0.2)
↓
Conv1D(128, kernel=5, ELU) → BatchNorm → MaxPool(2) → Dropout(0.2)
↓
Conv1D(256, kernel=3, ELU) → BatchNorm → Dropout(0.2)
↓
Flatten → Dense(128, ELU, L2) → Dropout(0.3)
↓
Dense(4, Softmax)
| Component | Setting |
|---|---|
| Optimizer | Adam (lr = 1e-3) |
| Loss Function | Focal Loss (γ = 2.0) |
| Class Weighting | Balanced, capped at 6.0 |
| Validation | 10% stratified split |
| Early Stopping | Patience = 7 (monitor: val_loss) |
| LR Scheduler | ReduceLROnPlateau (factor=0.5, patience=4) |
| Batch Size | 64 |
| Max Epochs | 100 |
Focal Loss was chosen over standard cross-entropy to handle class imbalance, particularly for the minority class (Coaly Shale). Class weights are additionally applied with a cap to prevent extreme over-weighting.
1D-CNN-WellLog-Lithology-Classification/
│
├── lowo_cnn_lithology.py # Main training and evaluation script
├── requirements.txt
├── .gitignore
└── README.md
To run this script on your own data, prepare one CSV file per well with at least the following columns:
| Column | Description |
|---|---|
DEPTH |
Measured depth (m) |
GR |
Gamma Ray (API) |
DENSITY |
Bulk density (g/cc) |
LITHO |
Lithology label (0–3) |
Place all CSV files in a single folder and update DATA_DIR in the script accordingly. Rows with missing values in any of these columns are automatically dropped.
The model was evaluated across 9 wells using Leave-One-Well-Out (LOWO) cross-validation.
| Well | Accuracy |
|---|---|
| Well-A | — |
| Well-B | — |
| Well-C | — |
| Well-D | — |
| Well-E | — |
| Well-F | — |
| Well-G | — |
| Well-H | — |
| Well-I | — |
| Mean | — |
| Std | — |
Fill in this table with your actual results.
pip install -r requirements.txt- Prepare your well CSV files (see Data Format above).
- Update
DATA_DIRandOUTPUT_DIRinlowo_cnn_lithology.py. - Run the script:
python lowo_cnn_lithology.pyKey parameters at the top of lowo_cnn_lithology.py:
WINDOW_SIZE = 101 # Sliding window length (depth samples)
FEATURES = ["GR", "DENSITY"]
N_CLASSES = 4
EPOCHS = 100
BATCH_SIZE = 64
MAX_CLASS_WEIGHT = 6.0 # Cap on class weightIf you use this code in your research or academic work, please cite:
Pangestu, D. K. (2025). 1D-CNN Well Log Lithology Classification using
Leave-One-Well-Out Cross-Validation. Undergraduate Thesis.
This project is licensed under the MIT License.