Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited tags
Link
Ethan
  • 1.7k
  • 9
  • 24
  • 39
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user

I've been following a tutorial on training a model and I've stumbled across an error that I've been struggling to find a solution tofor.

The code for the model training is bellow:

import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, MaxPooling2D import pickle

X = pickle.load(open("X.pickle", "rb")) y = pickle.load(open("y.pickle", "rb"))

X = X / 255.0

model = Sequential() model.add(Conv2D(64, (3, 3), input_shape = X.shape[1:])) model.add(Activation("relu")) model.add(MaxPooling2D(pool_size = (2, 2)))

model.add(Conv2D(64, (3, 3))) model.add(Activation("relu")) model.add(MaxPooling2D(pool_size = (2, 2)))

model.add(Flatten()) model.add(Dense(64))

model.add(Dense(1)) model.add(Activation("sigmoid"))

model.compile(loss = 'binary_crossentropy', optimizer = 'adam', metrics = ['accuracy'])

model.fit(X, y, batch_size=32, validation_split=0.1)

import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, MaxPooling2D
import pickle

X = pickle.load(open("X.pickle", "rb"))
y = pickle.load(open("y.pickle", "rb"))

X = X / 255.0

model = Sequential()
model.add(Conv2D(64, (3, 3), input_shape = X.shape[1:]))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size = (2, 2)))

model.add(Conv2D(64, (3, 3)))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size = (2, 2)))

model.add(Flatten())
model.add(Dense(64))

model.add(Dense(1))
model.add(Activation("sigmoid"))

model.compile(loss = 'binary_crossentropy',
             optimizer = 'adam',
             metrics = ['accuracy'])

model.fit(X, y, batch_size=32, validation_split=0.1)
---------------------------------------------------------------------------

ValueError Traceback (most recent call last) in 28 metrics = ['accuracy']) 29 ---> 30 model.fit(X, y, batch_size=32, validation_split=0.1)

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\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_freq, max_queue_size, workers, use_multiprocessing, **kwargs) 731 max_queue_size=max_queue_size, 732 workers=workers, --> 733 use_multiprocessing=use_multiprocessing) 734 735 def evaluate(self,

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in fit(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, **kwargs) 215 validation_data=validation_data, 216 validation_steps=validation_steps, --> 217 distribution_strategy=strategy) 218 219 total_samples = _get_total_number_of_samples(training_data_adapter)

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in _process_training_inputs(model, x, y, batch_size, sample_weights, class_weights, steps_per_epoch, validation_split, validation_data, validation_steps, shuffle, distribution_strategy) 468 'at same time.') 469 --> 470 adapter_cls = data_adapter.select_data_adapter(x, y) 471 472 # Handle validation_split, we want to split the data and get the training

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py in select_data_adapter(x, y) 446 "Failed to find data adapter that can handle " 447 "input: {}, {}".format( --> 448 _type_name(x), _type_name(y))) 449 elif len(adapter_cls) > 1: 450 raise RuntimeError(

ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, (<class 'list'> containing values of types {"<class 'int'>"})

ValueError Traceback (most recent call last) in 28 metrics = ['accuracy']) 29 ---> 30 model.fit(X, y, batch_size=32, validation_split=0.1)

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\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_freq, max_queue_size, workers, use_multiprocessing, **kwargs) 731 max_queue_size=max_queue_size, 732 workers=workers, --> 733 use_multiprocessing=use_multiprocessing) 734 735 def evaluate(self,

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in fit(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, **kwargs) 215 validation_data=validation_data, 216 validation_steps=validation_steps, --> 217 distribution_strategy=strategy) 218 219 total_samples = _get_total_number_of_samples(training_data_adapter)

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in _process_training_inputs(model, x, y, batch_size, sample_weights, class_weights, steps_per_epoch, validation_split, validation_data, validation_steps, shuffle, distribution_strategy) 468 'at same time.') 469 --> 470 adapter_cls = data_adapter.select_data_adapter(x, y) 471 472 # Handle validation_split, we want to split the data and get the training

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py in select_data_adapter(x, y) 446 "Failed to find data adapter that can handle " 447 "input: {}, {}".format( --> 448 _type_name(x), _type_name(y))) 449 elif len(adapter_cls) > 1: 450 raise RuntimeError(

ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, (<class 'list'> containing values of types {"<class 'int'>"})

I've been following a tutorial on training a model and I've stumbled across an error that I've been struggling to find a solution to.

The code for the model training is bellow:

import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, MaxPooling2D import pickle

X = pickle.load(open("X.pickle", "rb")) y = pickle.load(open("y.pickle", "rb"))

X = X / 255.0

model = Sequential() model.add(Conv2D(64, (3, 3), input_shape = X.shape[1:])) model.add(Activation("relu")) model.add(MaxPooling2D(pool_size = (2, 2)))

model.add(Conv2D(64, (3, 3))) model.add(Activation("relu")) model.add(MaxPooling2D(pool_size = (2, 2)))

model.add(Flatten()) model.add(Dense(64))

model.add(Dense(1)) model.add(Activation("sigmoid"))

model.compile(loss = 'binary_crossentropy', optimizer = 'adam', metrics = ['accuracy'])

model.fit(X, y, batch_size=32, validation_split=0.1)

---------------------------------------------------------------------------

ValueError Traceback (most recent call last) in 28 metrics = ['accuracy']) 29 ---> 30 model.fit(X, y, batch_size=32, validation_split=0.1)

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\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_freq, max_queue_size, workers, use_multiprocessing, **kwargs) 731 max_queue_size=max_queue_size, 732 workers=workers, --> 733 use_multiprocessing=use_multiprocessing) 734 735 def evaluate(self,

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in fit(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, **kwargs) 215 validation_data=validation_data, 216 validation_steps=validation_steps, --> 217 distribution_strategy=strategy) 218 219 total_samples = _get_total_number_of_samples(training_data_adapter)

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in _process_training_inputs(model, x, y, batch_size, sample_weights, class_weights, steps_per_epoch, validation_split, validation_data, validation_steps, shuffle, distribution_strategy) 468 'at same time.') 469 --> 470 adapter_cls = data_adapter.select_data_adapter(x, y) 471 472 # Handle validation_split, we want to split the data and get the training

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py in select_data_adapter(x, y) 446 "Failed to find data adapter that can handle " 447 "input: {}, {}".format( --> 448 _type_name(x), _type_name(y))) 449 elif len(adapter_cls) > 1: 450 raise RuntimeError(

ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, (<class 'list'> containing values of types {"<class 'int'>"})

I've been following a tutorial on training a model and I've stumbled across an error that I've been struggling to find a solution for.

The code for the model training is bellow:

import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, MaxPooling2D
import pickle

X = pickle.load(open("X.pickle", "rb"))
y = pickle.load(open("y.pickle", "rb"))

X = X / 255.0

model = Sequential()
model.add(Conv2D(64, (3, 3), input_shape = X.shape[1:]))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size = (2, 2)))

model.add(Conv2D(64, (3, 3)))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size = (2, 2)))

model.add(Flatten())
model.add(Dense(64))

model.add(Dense(1))
model.add(Activation("sigmoid"))

model.compile(loss = 'binary_crossentropy',
             optimizer = 'adam',
             metrics = ['accuracy'])

model.fit(X, y, batch_size=32, validation_split=0.1)

ValueError Traceback (most recent call last) in 28 metrics = ['accuracy']) 29 ---> 30 model.fit(X, y, batch_size=32, validation_split=0.1)

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\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_freq, max_queue_size, workers, use_multiprocessing, **kwargs) 731 max_queue_size=max_queue_size, 732 workers=workers, --> 733 use_multiprocessing=use_multiprocessing) 734 735 def evaluate(self,

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in fit(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, **kwargs) 215 validation_data=validation_data, 216 validation_steps=validation_steps, --> 217 distribution_strategy=strategy) 218 219 total_samples = _get_total_number_of_samples(training_data_adapter)

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in _process_training_inputs(model, x, y, batch_size, sample_weights, class_weights, steps_per_epoch, validation_split, validation_data, validation_steps, shuffle, distribution_strategy) 468 'at same time.') 469 --> 470 adapter_cls = data_adapter.select_data_adapter(x, y) 471 472 # Handle validation_split, we want to split the data and get the training

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py in select_data_adapter(x, y) 446 "Failed to find data adapter that can handle " 447 "input: {}, {}".format( --> 448 _type_name(x), _type_name(y))) 449 elif len(adapter_cls) > 1: 450 raise RuntimeError(

ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, (<class 'list'> containing values of types {"<class 'int'>"})

Source Link

Keras error "Failed to find data adapter that can handle input" while trying to train a model

I've been following a tutorial on training a model and I've stumbled across an error that I've been struggling to find a solution to.

The code for the model training is bellow:

import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, MaxPooling2D import pickle

X = pickle.load(open("X.pickle", "rb")) y = pickle.load(open("y.pickle", "rb"))

X = X / 255.0

model = Sequential() model.add(Conv2D(64, (3, 3), input_shape = X.shape[1:])) model.add(Activation("relu")) model.add(MaxPooling2D(pool_size = (2, 2)))

model.add(Conv2D(64, (3, 3))) model.add(Activation("relu")) model.add(MaxPooling2D(pool_size = (2, 2)))

model.add(Flatten()) model.add(Dense(64))

model.add(Dense(1)) model.add(Activation("sigmoid"))

model.compile(loss = 'binary_crossentropy', optimizer = 'adam', metrics = ['accuracy'])

model.fit(X, y, batch_size=32, validation_split=0.1)

And the result I get when I run this code is:

---------------------------------------------------------------------------

ValueError Traceback (most recent call last) in 28 metrics = ['accuracy']) 29 ---> 30 model.fit(X, y, batch_size=32, validation_split=0.1)

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\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_freq, max_queue_size, workers, use_multiprocessing, **kwargs) 731 max_queue_size=max_queue_size, 732 workers=workers, --> 733 use_multiprocessing=use_multiprocessing) 734 735 def evaluate(self,

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in fit(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, **kwargs) 215 validation_data=validation_data, 216 validation_steps=validation_steps, --> 217 distribution_strategy=strategy) 218 219 total_samples = _get_total_number_of_samples(training_data_adapter)

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py in _process_training_inputs(model, x, y, batch_size, sample_weights, class_weights, steps_per_epoch, validation_split, validation_data, validation_steps, shuffle, distribution_strategy) 468 'at same time.') 469 --> 470 adapter_cls = data_adapter.select_data_adapter(x, y) 471 472 # Handle validation_split, we want to split the data and get the training

~\Miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\data_adapter.py in select_data_adapter(x, y) 446 "Failed to find data adapter that can handle " 447 "input: {}, {}".format( --> 448 _type_name(x), _type_name(y))) 449 elif len(adapter_cls) > 1: 450 raise RuntimeError(

ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, (<class 'list'> containing values of types {"<class 'int'>"})

Thank you in advance if you can help me figure out where the problem is.