Skip to content
Theano implementation of our paper 'Developing a Long Short-Term Memory (LSTM) based Model for Predicting Water Table Depth in Agricultural Areas', Journal of Hydrology.
Jupyter Notebook Python
Branch: master
Clone or download
Latest commit fcc8904 Mar 8, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
checkpoints Completed Version Apr 9, 2018
data Completed Version Apr 18, 2018
doc Completed Version Apr 10, 2018
.gitignore Completed Version Apr 10, 2018
LICENSE Create LICENSE Apr 6, 2018
README.md Update README.md Mar 8, 2019
demo.py Completed Version Apr 18, 2018
layers.py Completed Version Apr 9, 2018
models.py Completed Version Apr 10, 2018
run_model.py Completed Version Apr 10, 2018
tutorials.ipynb Completed Version Apr 18, 2018
utils.py Completed Version Apr 10, 2018

README.md

LSTM based Model for Water Table Depth Prediction

Introduction

This is a Theano implementation of our work Developing a Long Short-Term Memory (LSTM) based Model for Predicting Water Table Depth in Agricultural Areas. [Paper]

NEW: PyTorch implementation also available: Water-Table-Depth-Prediction-PyTorch!

Requirements

Python3.x(Tested with 3.5)
theano(Tested with 1.0.1)
numpy
pandas
scikit-learn

Installation

The code was tested with Python 3.5. To use this code, please do:

  1. Clone the repo:

    git clone https://github.com/jfzhang95/LSTM-water-table-depth-prediction.git
    cd LSTM-water-table-depth-prediction
  2. Install dependencies:

    pip install theano matplotlib numpy pandas scikit-learn
  3. To try the demo code, please run:

    python demo.py

If installed correctly, the result should look like this: results

Noted that the demo data (demo.csv) are processed manually, so they are not real data, but they still can reflect the correlation between the original data.

Tutorials

A model training and testing pipeline can be defined as:

def LSTM_FC_prediction(X, Y, X_test=None, iters=20000, learning_rate=1e-4, dropout_prob=0.5):
    if dropout_prob > 1. or dropout_prob < 0.:
        raise Exception('Dropout level must be in interval [0, 1]')
    num_month = Y.shape[0]
    input_shathinkpe = X.shape[1]
    model = LSTM_FC_Model(num_input=input_shape, num_hidden=[40], num_output=1)
    print('Start training......')
    for iter in range(iters + 1):
        loss = model.fit(X, Y, learning_rate, dropout_prob)
        if iter % 1000 == 0:
            print("iteration: %s, loss: %s" % (iter, loss))
    # Saving model
    model.save_model_params('checkpoints/LSTM_FC_CKPT')

    print('Start predicting......')
    Y_test = model.predict(X_test)
    print('Done.')
    return Y_test

For more details, please see in tuitorials.

Citation

If you use this code, please consider citing the following paper:

@article{zjf18,
  journal        = {Journal of Hydrology},
  title          = {Developing a Long Short-Term Memory (LSTM) based Model for Predicting Water Table Depth in Agricultural Areas},
  author         = {Jianfeng Zhang, Yan Zhu, Xiaoping Zhang, Ming Ye and Jinzhong Yang},
  year           = {2018},
  volume         = {561},
  pages          = {918-929}
}

License

MIT

You can’t perform that action at this time.