TypeError: Unknown parameter type: <class 'theano.tensor.var.TensorVariable'> in Google Colab

382 Views Asked by At

The purpose to use Colab is because I am sharing the notebook with my professor, I ran this code on Jupyter Notebook and Pycharm and it worked normally, but when I ran this example in Google Colab exactly in this block:

train_mb = theano.function(
            [i], cost, updates=updates,
            givens={
                self.x:
                training_x[i*self.mini_batch_size: (i+1)*self.mini_batch_size],
                self.y:
                training_y[i*self.mini_batch_size: (i+1)*self.mini_batch_size]
            })

It returned me:

5 frames
<ipython-input-29-dc4534d01cf3> in main()
     12         SoftmaxLayer(n_in=10, n_out=2)], mini_batch_size)
     13 
---> 14     net.SGD(training_data, 60, mini_batch_size, 0.1, validation_data, test_data)

<ipython-input-24-2ee02f99d215> in SGD(self, training_data, epochs, mini_batch_size, eta, validation_data, test_data, lmbda)
     51                 training_x[i*self.mini_batch_size: (i+1)*self.mini_batch_size],
     52                 self.y:
---> 53                 training_y[i*self.mini_batch_size: (i+1)*self.mini_batch_size]
     54             })
     55         validate_mb_accuracy = theano.function(
....
....

TypeError: Unknown parameter type: <class 'theano.tensor.var.TensorVariable'>

The same goes when I execute this example from the Theano's website:

import theano
import theano.tensor as tt

x = tt.dmatrix('x')
s = 1 / (1 + tt.exp(-x))
logistic = theano.function([x], s)
logistic([[0, 1], [-1, -2]])
print([[ 0.5       ,  0.73105858],
       [ 0.26894142,  0.11920292]])

I have realized that this error occurs at the moment that the theano.function is called, how could I fix it?

0

There are 0 best solutions below