lmoroney / dlaicourse

Notebooks for learning deep learning
5.66k stars 5.37k forks source link

NLP Course - Week 3 Exercise #73

Open kermoonshahii opened 4 years ago

kermoonshahii commented 4 years ago

I run this code with tf=='2.2.0-rc1' and the code raises value error. Would you help me to solve this, please ? ValueError Traceback (most recent call last)

in () 11 12 num_epochs = 50 ---> 13 history = model.fit(training_sequences, training_labels, epochs=num_epochs, validation_data=(test_sequences, test_labels), verbose=2) 14 15 print("Training Complete") 3 frames /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py in _method_wrapper(self, *args, **kwargs) 63 def _method_wrapper(self, *args, **kwargs): 64 if not self._in_multi_worker_mode(): # pylint: disable=protected-access ---> 65 return method(self, *args, **kwargs) 66 67 # Running inside `run_distribute_coordinator` already. /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs) 748 workers=workers, 749 use_multiprocessing=use_multiprocessing, --> 750 model=self) 751 752 # Container that configures and calls `tf.keras.Callback`s. /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/data_adapter.py in __init__(self, x, y, sample_weight, batch_size, steps_per_epoch, initial_epoch, epochs, shuffle, class_weight, max_queue_size, workers, use_multiprocessing, model) 1094 self._insufficient_data = False 1095 -> 1096 adapter_cls = select_data_adapter(x, y) 1097 self._adapter = adapter_cls( 1098 x, /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/data_adapter.py in select_data_adapter(x, y) 958 "Failed to find data adapter that can handle " 959 "input: {}, {}".format( --> 960 _type_name(x), _type_name(y))) 961 elif len(adapter_cls) > 1: 962 raise RuntimeError( ValueError: Failed to find data adapter that can handle input: , ( containing values of types {""})
H-rim commented 4 years ago

I had same issue, and solved it by adding some code before 'model.fit()' training_sequences, test_sequences = np.array(training_sequences), np.array(test_sequences) training_labels, test_labels = np.array(training_labels), np.array(test_labels)

refer to this link: https://stackoverflow.com/questions/58682026/failed-to-find-data-adapter-that-can-handle-input-class-numpy-ndarray-cl