1

I could see element wise matrix multiplication using numpy can be done with * operator.

print np.mat(np.ones((10,10)))*np.mat(np.ones((10,10)))

But couldnt get it working under theano. The code I tried is

x = T.dmatrix('x')
y = T.dmatrix('y')
z = x * y
f1 = theano.function([x, y], z)

print f1(np.mat(np.ones((10,10))),np.mat(np.ones((10,10))))
user567879
  • 5,139
  • 20
  • 71
  • 105

1 Answers1

4

If I try the following (which is basically your code):

import theano
import theano.tensor as T

import numpy as np

x = T.dmatrix('x')
y = T.dmatrix('y')
z = x * y
f1 = theano.function([x, y], z)

print f1(np.mat(np.ones((10,10))),np.mat(np.ones((10,10))))

I get the following:

[[ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]
 [ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]
 [ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]
 [ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]
 [ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]
 [ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]
 [ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]
 [ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]
 [ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]
 [ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]]

So, it works for me.

Roman
  • 124,451
  • 167
  • 349
  • 456