Skip to content

Instantly share code, notes, and snippets.

@MarcCote
Created February 19, 2014 19:35
Show Gist options
  • Save MarcCote/9099852 to your computer and use it in GitHub Desktop.
Save MarcCote/9099852 to your computer and use it in GitHub Desktop.
Gist showing an erroneous result from tensor.dot when one of the operand is zero.
import numpy as np
import theano
import theano.tensor as T
print "Version:", theano.version.version
print "=Theano="
A = T.zeros((2,10))
B = T.zeros((30, 10))
print "Shape of A:", A.eval().shape
print "Shape of B:", B.eval().shape
print "AB =\n", T.dot(A,B).eval()
print "Shape of AB:", T.dot(A,B).eval().shape
print "=Numpy="
A = np.zeros((2,10))
B = np.zeros((30, 10))
print "Shape of A:", A.shape
print "Shape of B:", B.shape
print "AB =", np.dot(A,B)
print "Shape of AB:", np.dot(A,B).shape
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment