I get exactly the same error, when I try that. I put an ipdb.set_trace  in the custom dataset class to inspect the incoming idx. See image attached 
Screen Shot 2018-08-03 at 15.40.23.png996×486 52.9 KB