After replacing tens_a and tens_b by tt.dmatrix, I run into another problem.
The operation returns [None, None] instead of the result that I expect.
Test:
import numpy as np
import theano.tensor as tt
import theano
class MyOp(tt.Op):
itypes = [tt.dmatrix, tt.dmatrix]
otypes = [tt.dmatrix, tt.dmatrix]
def __init__(self):
pass
def perform(self, node, inputs, outputs):
mat_a, mat_b = inputs
outputs[0] = 2 * mat_a
outputs[1] = 3 * mat_b
def main():
tens_a = tt.dmatrix('a')
tens_b = tt.dmatrix('b')
funct = MyOp()(tens_a, tens_b)
f = theano.function([tens_a, tens_b], funct)
dtype = np.float64
mat_a = np.ones((3, 3), dtype=dtype)
mat_b = np.ones((3, 3), dtype=dtype)
print(f(mat_a, mat_b))
main()
Result:
[None, None]