Imported from https://github.com/alexander-rakhlin/ICIAR2018