Imported from https://github.com/pnxenopoulos/cav-keras