Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wselina opened this issue Dec 11, 2021 · 3 comments

Comments

@wselina
Copy link

wselina commented Dec 11, 2021

> Using Theano backend.
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call last)
> <ipython-input-6-8f2d52484ded> in <module>()
>       5 
>       6 from ExternalLibs.emotion_predictor import EmotionPredictor
> ----> 7 model = EmotionPredictor(classification='ekman', setting='mc')
> 
> 20 frames
> /content/gdrive/.shortcut-targets-by-id/1pkR0QqFxHduImxgwAN7Sx8ROr_iPhgfd/sw/emotion_predictor.py in __init__(self, classification, setting, use_unison_model)
>      28         self.setting = setting
>      29         self.use_unison_model = use_unison_model
> ---> 30         self.model = self._get_model()
>      31         self.embeddings_model = self._get_embeddings_model()
>      32         self.char_to_ind = self._get_char_mapping()
> 
> /content/gdrive/.shortcut-targets-by-id/1pkR0QqFxHduImxgwAN7Sx8ROr_iPhgfd/sw/emotion_predictor.py in _get_model(self)
>      40             self.setting,
>      41         )
> ---> 42         return load_model(self._loaded_model_filename)
>      43 
>      44     def _get_embeddings_model(self):
> 
> /usr/local/lib/python3.7/dist-packages/keras/models.py in load_model(filepath, custom_objects)
>     126         raise ValueError('No model found in config file.')
>     127     model_config = json.loads(model_config.decode('utf-8'))
> --> 128     model = model_from_config(model_config, custom_objects=custom_objects)
>     129 
>     130     # set weights
> 
> /usr/local/lib/python3.7/dist-packages/keras/models.py in model_from_config(config, custom_objects)
>     175         raise Exception('`model_fom_config` expects a dictionary, not a list. '
>     176                         'Maybe you meant to use `Sequential.from_config(config)`?')
> --> 177     return layer_from_config(config, custom_objects=custom_objects)
>     178 
>     179 
> 
> /usr/local/lib/python3.7/dist-packages/keras/utils/layer_utils.py in layer_from_config(config, custom_objects)
>      34         layer_class = get_from_module(class_name, globals(), 'layer',
>      35                                       instantiate=False)
> ---> 36     return layer_class.from_config(config['config'])
>      37 
>      38 
> 
> /usr/local/lib/python3.7/dist-packages/keras/engine/topology.py in from_config(cls, config, custom_objects)
>    2373 
>    2374         for layer_data in config['layers']:
> -> 2375             process_layer(layer_data)
>    2376 
>    2377         name = config.get('name')
> 
> /usr/local/lib/python3.7/dist-packages/keras/engine/topology.py in process_layer(layer_data)
>    2368                 if input_tensors:
>    2369                     if len(input_tensors) == 1:
> -> 2370                         layer(input_tensors[0])
>    2371                     else:
>    2372                         layer(input_tensors)
> 
> /usr/local/lib/python3.7/dist-packages/keras/engine/topology.py in __call__(self, x, mask)
>     512         if inbound_layers:
>     513             # this will call layer.build() if necessary
> --> 514             self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
>     515             input_added = True
>     516 
> 
> /usr/local/lib/python3.7/dist-packages/keras/engine/topology.py in add_inbound_node(self, inbound_layers, node_indices, tensor_indices)
>     570         # creating the node automatically updates self.inbound_nodes
>     571         # as well as outbound_nodes on inbound layers.
> --> 572         Node.create_node(self, inbound_layers, node_indices, tensor_indices)
>     573 
>     574     def get_output_shape_for(self, input_shape):
> 
> /usr/local/lib/python3.7/dist-packages/keras/engine/topology.py in create_node(cls, outbound_layer, inbound_layers, node_indices, tensor_indices)
>     147 
>     148         if len(input_tensors) == 1:
> --> 149             output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
>     150             output_masks = to_list(outbound_layer.compute_mask(input_tensors[0], input_masks[0]))
>     151             # TODO: try to auto-infer shape if exception is raised by get_output_shape_for
> 
> /usr/local/lib/python3.7/dist-packages/keras/layers/core.py in call(self, x, mask)
>      88         if 0. < self.p < 1.:
>      89             noise_shape = self._get_noise_shape(x)
> ---> 90             x = K.in_train_phase(K.dropout(x, self.p, noise_shape), x)
>      91         return x
>      92 
> 
> /usr/local/lib/python3.7/dist-packages/keras/backend/theano_backend.py in dropout(x, level, noise_shape, seed)
>    1014 
>    1015     if noise_shape is None:
> -> 1016         random_tensor = rng.binomial(x.shape, p=retain_prob, dtype=x.dtype)
>    1017     else:
>    1018         random_tensor = rng.binomial(noise_shape, p=retain_prob, dtype=x.dtype)
> 
> /usr/local/lib/python3.7/dist-packages/theano/sandbox/rng_mrg.py in binomial(self, size, n, p, ndim, dtype, nstreams, **kwargs)
>     899         if n == 1:
>     900             p = undefined_grad(as_tensor_variable(p))
> --> 901             x = self.uniform(size=size, nstreams=nstreams, **kwargs)
>     902             return cast(x < p, dtype)
>     903         else:
> 
> /usr/local/lib/python3.7/dist-packages/theano/sandbox/rng_mrg.py in uniform(self, size, low, high, ndim, dtype, nstreams, **kwargs)
>     870         if nstreams is None:
>     871             nstreams = self.n_streams(size)
> --> 872         rstates = self.get_substream_rstates(nstreams, dtype)
>     873 
>     874         d = {}
> 
> /usr/local/lib/python3.7/dist-packages/theano/configparser.py in res(*args, **kwargs)
>     115         def res(*args, **kwargs):
>     116             with self:
> --> 117                 return f(*args, **kwargs)
>     118         return res
>     119 
> 
> /usr/local/lib/python3.7/dist-packages/theano/sandbox/rng_mrg.py in get_substream_rstates(self, n_streams, dtype, inc_rstate)
>     777         # If multMatVect.dot_modulo isn't compiled, compile it.
>     778         if multMatVect.dot_modulo is None:
> --> 779             multMatVect(rval[0], A1p72, M1, A2p72, M2)
>     780 
>     781         # This way of calling the Theano fct is done to bypass Theano overhead.
> 
> /usr/local/lib/python3.7/dist-packages/theano/sandbox/rng_mrg.py in multMatVect(v, A, m1, B, m2)
>      60         o = DotModulo()(A_sym, s_sym, m_sym, A2_sym, s2_sym, m2_sym)
>      61         multMatVect.dot_modulo = function(
> ---> 62             [A_sym, s_sym, m_sym, A2_sym, s2_sym, m2_sym], o, profile=False)
>      63 
>      64     # This way of calling the Theano fct is done to bypass Theano overhead.
> 
> /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'>
@nikicc
Copy link
Owner

nikicc commented Dec 13, 2021

Hmm, not sure. The first thing I'd check is if the version of Theano is exactly the same as specified in the requirements.txt file. Also, make sure all the other dependencies are installed and match the versions exactly.

@wselina
Copy link
Author

wselina commented Dec 13, 2021

Hmm, not sure. The first thing I'd check is if the version of Theano is exactly the same as specified in the requirements.txt file. Also, make sure all the other dependencies are installed and match the versions exactly.

Yes, I installed everything exactly as stated in the requirements. Also tried installing the dependencies without the specified versions, but it didn't work.

@mareloraby
Copy link

I've got the same issue while working on google colab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants