TypeError: Unknown parameter type: <class ‘theano.tensor.var.TensorVariable’> with theano

In Neural Networks and Deep Learning, there’s an object called network3 (which is a PY file, written for python 2.7 and theano 0.7). I modified it to run with python 3.9 and theano 1.0.3. However, when I run the following code (in google colab):

import network3
from network3 import Network
from network3 import ConvPoolLayer , FullyConnectedLayer , SoftmaxLayer

training_data , validation_data , test_data = network3.load_data_shared()

mini_batch_size = 10

net = Network([FullyConnectedLayer(n_in=784, n_out=100),
           SoftmaxLayer(n_in=100, n_out=10)], mini_batch_size)

net.SGD(training_data , 60, mini_batch_size , 0.1, validation_data , test_data)    

It returned a lot of error:

TypeError                                 Traceback (most recent call last)
<ipython-input-7-64fde00f9b37> in <module>()
 11         SoftmaxLayer(n_in=100, n_out=10)], mini_batch_size)
 12 net.SGD(training_data, 60, mini_batch_size, 0.1, 
---> 13             validation_data, test_data)

<ipython-input-5-bbd2070e7d9a> in SGD(self, training_data, epochs, mini_batch_size, eta, 
validation_data, test_data, lmbda)
 76                 training_x[i*self.mini_batch_size: (i+1)*self.mini_batch_size],
 77                 self.y:
 ---> 78                 training_y[i*self.mini_batch_size: (i+1)*self.mini_batch_size]
 79             })
 80         validate_mb_accuracy = theano.function(


/usr/local/lib/python3.7/dist-packages/theano/compile/function/__init__.py in function(inputs, 
outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, 
allow_input_downcast, profile, on_unused_input)
348             on_unused_input=on_unused_input,
349             profile=profile,
--> 350             output_keys=output_keys,
351         )
352     return fn


/usr/local/lib/python3.7/dist-packages/theano/compile/function/pfunc.py in pfunc(params, 
outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, 
allow_input_downcast, profile, on_unused_input, output_keys)
425     # transform params into theano.compile.In objects.
426     inputs = [
--> 427         _pfunc_param_to_in(p, allow_downcast=allow_input_downcast) for p in params
428     ]
429 


/usr/local/lib/python3.7/dist-packages/theano/compile/function/pfunc.py in <listcomp>(.0)
425     # transform params into theano.compile.In objects.
426     inputs = [
--> 427         _pfunc_param_to_in(p, allow_downcast=allow_input_downcast) for p in params
428     ]
429 

/usr/local/lib/python3.7/dist-packages/theano/compile/function/pfunc.py in 
_pfunc_param_to_in(param, strict, allow_downcast)
541     elif isinstance(param, In):
542         return param
--> 543     raise TypeError(f"Unknown parameter type: {type(param)}")
544 
545 



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

I have googled the issues but couldn’t find relevant solution. Could you please help?

Thanks in advance.

Source: Python Questions

LEAVE A COMMENT