                  input_grads = node.op.grad(inputs, new_output_grads)
  
                  if input_grads is None:
-@@ -1292,11 +1300,11 @@
+@@ -1292,11 +1300,17 @@
                          if isinstance(term.type, DisconnectedType):
                              continue
  

-                                ("%s.grad returned a term with"
-                                 " %d dimensions, but %d are required.") % (
-                                     str(node.op), term.ndim, var.ndim))
+                        # if hasattr(var, 'ndim') and term.ndim != var.ndim:
+                        #     raise ValueError(
+                        #         ("%s.grad returned a term with"

Only in theano-base/theano/gof: sandbox
diff -x '*.pyc' -uwr theano-base/theano/gradient.py theano/gradient.py
--- theano-base/theano/gradient.py	2016-02-25 15:14:41.434999962 -0800
+++ theano/gradient.py	2016-02-27 20:10:36.933998714 -0800
@@ -361,7 +361,8 @@
 
 def grad(cost, wrt, consider_constant=None,
