This repository contains the Python code used to train, evaluate, and compare expert-defined and AutoML-generated deep learning models for tool condition monitoring (TCM) in face milling, as presented in Chapter 4 of the PhD thesis:
Peralta Abadía, J.J. Enhancing Smart Monitoring in Face Milling with Deep Continual Learning. Mondragon Unibertsitatea, 2025.
This work was developed at the Software and systems engineering and the High-performance machining groups at Mondragon University, as part of the Digital Manufacturing and Design Training Network.
This project has received funding from the European Union’s Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie grant agreement No 814078 (DIMAND) and by the Department of Education, Universities and Research of the Basque Government under the projects Ikerketa Taldeak (Grupo de Ingeniería de Software y Sistemas IT1519-22 and Grupo de investigación de Mecanizado de Alto Rendimiento IT1443-22).
This repository implements two complementary approaches for tool flank wear (VB) prediction using deep learning:
-
Expert-defined models
- Custom architectures leveraging domain knowledge (e.g., Meta-learning Ensembles and Robust ResNet).
- Designed and optimized manually following state-of-the-art deep learning methods for regression in TCM.
- Described in:
- Peralta Abadía et al., Procedia CIRP, 2024
- Peralta Abadía et al., DYNA, 2024
-
AutoML-generated models
- Automatically searched and optimized architectures using AutoKeras.
- Incorporates multimodal learning by combining signal-based and process-information networks.
- Demonstrates the feasibility of AutoML in scalable TCM model design.
Both model types were trained and benchmarked using the NASA Ames Milling Dataset.
AutoML-vs-Expert-TCM/
├── data/
│ ├── datasets.py # Custom PyTorch Dataset Loader
│ ├── nasa.bin # Preprocessed binary files (generated automatically)
│ └── mat_to_csv.py # Scripts for converting original MAT files
├── models/
│ ├── dl_models.py # Expert model definitions (CNN, LSTM, etc.)
│ ├── autokeras_blocks.py # AutoKeras blocks and hypermodels
│ ├── preprocessing_tuner.py # Keras Tuner for preprocessing steps
│ └── generative.py # Generative models (VAE, GAN)
├── helpers/
│ └── preprocessing.py # Signal processing functions
├── train.py # Main script for training expert models
├── train_ak.py # Main script for AutoKeras search and training
├── requirements.txt
├── README.md
└── LICENSE
- Python ≥ 3.9
- TensorFlow ≥ 2.9
- Keras ≥ 3.0 (with Torch backend)
- AutoKeras
- NumPy
- Pandas
- Scikit-learn
- Matplotlib
pip install -r requirements.txtThis repository includes a Dockerfile to create a reproducible deep learning environment. The container is configured to automatically launch a Jupyter Notebook server, which can be accessed directly from your web browser.
To build the Docker image from the source, run:
docker build -t [image_name] .To run the container with GPU support and mount the repository volume:
docker run -it --gpus all -p 8889:8889 -v ~/DeepTCM:/workspace/DeepTCM --runtime=nvidia [image_name]Notes:
- This command starts a Jupyter Notebook server exposed on port
8889. - Access the notebook by opening
http://localhost:8889in your web browser. - The
--gpus alland--runtime=nvidiaflags are required to enable GPU acceleration inside the container. - The volume mount
-v ~/DeepTCM:/workspace/DeepTCMensures that your changes and data are persisted locally.
Trains manual "expert" models (CNN, LSTM, Transformer, Ensembles) on the NASA dataset.
python train.py [options]Options:
-e <epochs>: Number of epochs (default: 300)-r <0 or 1>: Resume training from existing checkpoints (default: 1)-t: Enable test mode (runs faster on simplified data)-c <0 or 1>: Use generative models for augmentation (default: 0)-w <int>: Moving average window size (default: 10)
Example:
python train.py -e 500 -w 10 -r 0Runs an AutoKeras search to find the best model architecture, combined with a Preprocessing Tuner to optimize signal processing steps.
python train_ak.py [options]Options:
-e <epochs>: Number of epochs for the final model training (default: 300)-r <0 or 1>: Resume training (default: 1)-w <int>: Moving average window size (default: 10)-o <int>: Number of Outer Trials (Preprocessing Tuner) (default: 20)-i <int>: Number of Inner Trials (AutoKeras Search) (default: 50)
Example:
python train_ak.py -o 10 -i 30 -e 200History of model performance:
- Initial Success (with Leakage): Early models achieved very low RMSE but suffered from data leakage (likely due to random splitting of windows instead of runs).
- Current Status (Fixed Leakage): After enforcing a rigorous "Leave-Runs-Out" split strategy to prevent leakage, the model performance dropped significantly.
- Goal: Drive RMSE down from ~0.06 to State-of-the-Art (SOTA) levels (0.01 - 0.04) observed in literature, using legitimate non-leaking preprocessing and robust architectures.
- Current Attempt: Implemented a
PreprocessingTunerto automatically search for the best combination of noise reduction (MA, RMS, Filters), detrending, and scalogram types (CWT, FSST, WSST).
Current investigations to bridge the performance gap:
-
Preprocessing & Standardization:
- Winsorization: Clip extreme outliers before normalization to prevent skewing (currently implemented as an option in Tuner).
-
Data Loading Strategy:
- Split Strategy: One run from each case is extracted for test and for val. Other option is cases split (Leave-One-Case-Out) but that reduced performance even more.
- Windowing: Tuning window size (before 500 currently 100) and stride (50). Smaller strides (more overlap) act as augmentation.
NASA Ames/UC Berkeley face-milling open-access dataset
Source: NASA Ames Prognostics Data Repository
If you use this repository or its associated datasets, please cite the following works:
@article{Peralta2024a,
author = {José{-}Joaquín Peralta Abadía and Mikel Cuesta Zabaljauregui and Félix Larrinaga Barrenechea},
title = {A meta-learning strategy based on deep ensemble learning for tool condition monitoring of machining processes},
journal = {Procedia CIRP},
volume = {126},
pages = {429--434},
year = {2024},
doi = {10.1016/j.procir.2024.08.391}
}
@article{Peralta2024b,
author = {José{-}Joaquín Peralta Abadía and Mikel Cuesta Zabaljauregui and Félix Larrinaga Barrenechea},
title = {Tool condition monitoring in machining using robust residual neural networks},
journal = {DYNA},
volume = {99},
number = {5},
year = {2024}
}
@dataset{Peralta2025a,
author = {José{-}Joaquín Peralta Abadía and Mikel Cuesta Zabaljauregui and Félix Larrinaga Barrenechea},
title = {MU-TCM face-milling dataset},
year = {2025},
howpublished = {\url{https://hdl.handle.net/20.500.11984/6926}}
}