nikicc / twitter-emotion-recognition

Models for predicting emotions from English tweets.
GNU Affero General Public License v3.0
164 stars 67 forks source link

ValueError: Unrecognized keyword arguments: ['input_dtype'] #34

Open RakeshPardeshi opened 1 year ago

RakeshPardeshi commented 1 year ago

I am getting an error while using below code from the python library. Please can anyone help to resolve it?

model = EmotionPredictor(classification='ekman', setting='mc') model.predict_probabilities(FJ_FP['Cleaned'])

ValueError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_1676\1528171436.py in ----> 1 model = EmotionPredictor(classification='ekman', setting='mc') 2 model.predict_probabilities(FJ_FP['Cleaned'])

~\Documents\DSA_Task\AbhishekPoddar\Code\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()

~\Documents\DSA_Task\AbhishekPoddar\Code\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):

~\anaconda3\lib\site-packages\keras\utils\traceback_utils.py in error_handler(*args, **kwargs) 68 # To get the full stack trace, call: 69 # tf.debugging.disable_traceback_filtering() ---> 70 raise e.with_traceback(filtered_tb) from None 71 finally: 72 del filtered_tb

~\anaconda3\lib\site-packages\keras\engine\input_layer.py in init(self, input_shape, batch_size, dtype, input_tensor, sparse, name, ragged, type_spec, **kwargs) 150 input_shape = batch_input_shape[1:] 151 if kwargs: --> 152 raise ValueError( 153 f"Unrecognized keyword arguments: {list(kwargs.keys())}" 154 )

ValueError: Unrecognized keyword arguments: ['input_dtype']

nikicc commented 1 year ago

HI @RakeshPardeshi. Not sure, but errors like this usually mean that some environment dependencies are incorrect. Some things to check:

  1. Also, can you double check that backend in Keras is set to Theano, not TensorFlow. See how we do it in demo.py or check this tutorial.
  2. Is the version of Theano is exactly the same as specified in the requirements.txt file.
  3. Make sure all the other dependencies are installed and match the versions exactly the versions specified in the requirements.txt file.
RakeshPardeshi commented 1 year ago

Hi @nikicc, Thank you for your reply. I tried to install the packages as per the version s specified. However, while installing h5py, I am getting following error (last few lines are copied):

creating build\temp.win-amd64-cpython-39\Release\Users\DELL\AppData\Local\Temp\pip-install-37o7nv9m\h5py_0f53c4d0f2c943db9d15b7a23cb8aa15\h5py "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DH5_USE_16_API -DHDF5USEDLL -DH5_BUILT_AS_DYNAMIC_LIB -I.\h5py -IC:\Users\DELL\AppData\Local\Temp\pip-install-37o7nv9m\h5py_0f53c4d0f2c943db9d15b7a23cb8aa15\lzf -IC:\Users\DELL\AppData\Local\Temp\pip-install-37o7nv9m\h5py_0f53c4d0f2c943db9d15b7a23cb8aa15\windows -IC:\Users\DELL\anaconda3\lib\site-packages\numpy\core\include -IC:\Users\DELL\anaconda3\include -IC:\Users\DELL\anaconda3\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /TcC:\Users\DELL\AppData\Local\Temp\pip-install-37o7nv9m\h5py_0f53c4d0f2c943db9d15b7a23cb8aa15\h5py\defs.c /Fobuild\temp.win-amd64-cpython-39\Release\Users\DELL\AppData\Local\Temp\pip-install-37o7nv9m\h5py_0f53c4d0f2c943db9d15b7a23cb8aa15\h5py\defs.obj defs.c C:\Users\DELL\anaconda3\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(14) : Warning Msg: Using deprecated NumPy API, disable it with #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION C:\Users\DELL\AppData\Local\Temp\pip-install-37o7nv9m\h5py_0f53c4d0f2c943db9d15b7a23cb8aa15\h5py\api_compat.h(27): fatal error C1083: Cannot open include file: 'hdf5.h': No such file or directory error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\bin\HostX86\x64\cl.exe' failed with exit code 2 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure

× Encountered error while trying to install package. ╰─> h5py

note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.

nikicc commented 1 year ago

I'm not sure what is causing this issue 🤔

SemouleSombre commented 1 year ago

Hello :) I have the same issue : I installed Python 3 at first, then I used to install all the requirements (with the last versions, I didn't knew about that) After that, I installed tensorflow, then I did : pip install -r requirement.txt

But the problem was here : I couldn't return to the past and I have many errors.

and the final is here : `TypeError: Error when deserializing class 'InputLayer' using config={'batch_input_shape': [None, 143], 'input_dtype': 'float32', 'name': 'input_1', 'sparse': False}.

Exception encountered: Unrecognized keyword arguments: ['input_dtype']`

Do I need to uninstall python 3 and reinstall it without tensorflow ? (and just unistall python will be feasible ?)

Thank you for your help :)

nikicc commented 1 year ago

I don't think you need to uninstall Python 3. If you only uninstall the dependencies, and then reinstall the right versions back, you should be good to go.

SemouleSombre commented 1 year ago

I tryied to uninstall and reinstall. But the numpy version seems to have problems to install : Collecting pandas==0.24.1 (from -r requirements.txt (line 4)) Using cached pandas-0.24.1.tar.gz (11.8 MB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully. │ exit code: 1 KeyError: 'numpy'

  ModuleNotFoundError: No module named 'numpy'
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.

But this one is installed without problem : Collecting numpy==1.16.0 (from -r requirements.txt (line 3)) Using cached numpy-1.16.0.zip (5.1 MB)