Predicting total battery cycle life time with TensorFlow 2. We're going to publish a blog post describing the project in-depth soon.
This project is based on the work done in the paper 'Data driven prediciton of battery cycle life before capacity degradation' by K.A. Severson, P.M. Attia, et al., and uses the corresponding data set. The original instructions for how to load the data can be found here.
We recommend to set up a virtual environment using a tool like Virtualenv.
Clone this repo
git clone https://github.com/dsr-18/long-live-the-battery
and install dependencies.
pip install -r requirements.txt
You can download the processed dataset here and jump to Train Model. If you want to reproduce the data preprocessing step, go ahead with Generate Local Data.
Before running the model, generate local data:
long-live-the-battery ├── data | ├── 2017-05-12_batchdata_updated_struct_errorcorrect.mat | ├── 2018-04-12_batchdata_updated_struct_errorcorrect.mat | └── 2017-06-30_batchdata_updated_struct_errorcorrect.mat
python -m trainer.data_preprocessing
to create a processed_data.pkl file.
python -m trainer.data_pipeline
to recreate the .tfrecord files.
Make sure the .tfrecord files are saved in this structure:
long-live-the-battery ├── data | ├── tfrecords | | ├── scaling_factors.csv | | ├── train | | ├── test | | └── secondary_test
To start training the model, run this command from the base directory:
python -m trainer.task
The default is set to three epochs which is okay for testing, but too short to train a reasonably fit model. Use the above command with the --num-epochs flag to set a higher number. To get a list of other parameters, use the --help flag.
To run the model in Google Cloud Platform (team members only):
Follow the output URL to stream logs.
Every training run saves a TensorBoard logfile and at least one model checkpoint by default in the Graph directory. One way to test your model's performance without writing your own TensorFlow Keras code is to start a local Flask server that serves predictions:
cd server python server.py