Fix bug caused by self.doc

This was giving me AttributeError. 
@goodfeli Am I missing something, and self.doc actually should be defined somewhere?