Theano / Theano

Theano was a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. It is being continued as PyTensor: www.github.com/pymc-devs/pytensor

Home Page:https://www.github.com/pymc-devs/pytensor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot convert a symbolic Tensor in theano.scan

IlyesAbdelhamid opened this issue · comments

Dear all,

I am trying to run the following command line:
dst, _ = theano.scan(lambda z_i: T.sqrt(((z_i - self.mu) ** 2).sum(axis=1)), sequences=z)
self.mu is declared as it follows: self.mu = K.variable(mu,dtype='float32'), with K calling the backend module from keras and T the theano.tensor module.
However it comes with this error message:
NotImplementedError: Cannot convert a symbolic Tensor (Relu_199:0) to a numpy array.
I use keras version 1.0.7, theano version 0.8.2 and tensorflow version 1.15 and python version 3.6.9.

The tensor to be looped over should be provided to scan using the sequence keyword argument as per the documentation of theano.scan. So to make sure, I am passing the required type, I print(z) right before the aforementioned command line.
Here is the outcome of print(z): Tensor("Relu_199:0", shape=(?, 10), dtype=float32)
I tried to force cast z into Tensor object (although it appears to be a tensor as per print(z) ), but in vain.

I appreciate your help in this matter.
Thank you!

Sincerely,
Ilyes