[WIP] fix gh-2091

When optimizer=None, we had a crash at Theano import time.

THEANO_FLAGS=optimizer=None,device=gpu python -c 'import theano'

don't merge, it still crash with optimizer=merge. I'll try to fix it at the same time.