Imported from https://github.com/zhangjiong724/spectral-RNN