0

In my code, my model is compiling fine but when I am using pd.get_dummies(pd.Series(test_labels)) to get the labels for the validation images, it gives me the following error.

File "train_model.py", line 43, in <module>
    pd.get_dummies(pd.Series(test_labels))])
  File "C:\Users\ariji\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 728, in fit
    use_multiprocessing=use_multiprocessing)
  File "C:\Users\ariji\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 224, in fit
    distribution_strategy=strategy)
  File "C:\Users\ariji\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 497, in _process_training_inputs
    adapter_cls = data_adapter.select_data_adapter(x, y)
  File "C:\Users\ariji\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py", line 653, in select_data_adapter
    _type_name(x), _type_name(y)))
ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, <class 'pandas.core.frame.DataFrame'>

What seems to be the issue? My model is a simple tensorflow sequential model.

1 Answer 1

1

That is because pd.get_dummies gives a pd.DataFrame. You need to convert that to numpy.ndarray type.

Try

pd.get_dummeis(pd.Series(test_labels)).to_numpy()
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, it worked. Somehow I got this problem when I was running an old code of mine with tf2. It used to work fine with the old tensorflow

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.