raiseValueError('shape mismatch in StructuredDot.perform',(a.shape,b.shape))
raiseValueError('shape mismatch in StructuredDot.perform',
(a.shape,b.shape))
#variable = a.dot(b) # deprecated
variable=a*b
ifisinstance(node.outputs[0].type,SparseType):
ifisinstance(node.outputs[0].type,SparseType):
assert_is_sparse(variable)
out[0]=variable
return
assert_is_dense(variable)# scipy 0.7 automatically converts to dense
assert_is_dense(variable)# scipy 0.7 automatically converts to dense
# dot of an NxM sparse matrix, with a Mx1 dense matrix, returns vector not matrix
# dot of an NxM sparse matrix, with a Mx1 dense matrix, returns vector
# not matrix
ifvariable.ndim==1:
variable=numpy.expand_dims(variable,1)
variable=numpy.expand_dims(variable,1)
elifvariable.ndim!=2:
raiseException('Output of structured dot should be a matrix (ndim=2)')
raiseException('Output of structured dot should be a matrix '
'(ndim=2)')
assertvariable.ndim==2
ifvariable.shape!=(a.shape[0],b.shape[1]):
ifb.shape[0]==1:
raiseException("a.shape=%s, b.shape=%s, variable.shape=%s ??? This is probably because scipy.csc_matrix dot has a bug with singleton dimensions (i.e. b.shape[0]=1), for scipy 0.6. Use scipy 0.7. NB you have scipy version %s"%(a.shape,b.shape,variable.shape,scipy.__version__))
raiseException("a.shape=%s, b.shape=%s, "
"variable.shape=%s ??? This is probably "
"because scipy.csc_matrix dot has a bug "
"with singleton dimensions (i.e. "
"b.shape[0]=1), for scipy 0.6. Use scipy "
"0.7. NB you have scipy version %s"%
(a.shape,b.shape,variable.shape,
scipy.__version__))
else:
raiseException("a.shape=%s, b.shape=%s, variable.shape=%s ??? I have no idea why")