Я проверил весь массив перед тем, как вводить их в функцию model.fit (), но функция model.fit () возвращает ValueError. Я приложил код ниже для вашей справки. Я также попытался однократным кодированием y_train и y_test, но все еще не смог соответствовать модели.
print(any(elem is None for elem in y_test))
print(any(elem is None for elem in x_traincnn))
print(any(elem is None for elem in x_testcnn))
print(any(elem is None for elem in y_train))
False
False
False
False
Эта часть кода не работает, и я понятия не имею, почему метод .fit не может распознать вектор x_traincnn
cnnhistory = model.fit(x=x_traincnn, y=y_train, batch_size=64, epochs=1000, validation_data=(x_testcnn, y_test))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-51-b07b93617f0d> in <module>
----> 1 cnnhistory = model.fit(x=x_traincnn, y=y_train, batch_size=64, epochs=1000, validation_data=(x_testcnn, y_test))
D:\Anacona3\envs\tf_gpuu\lib\site-packages\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)
1211 else:
1212 fit_inputs = x + y + sample_weights
-> 1213 self._make_train_function()
1214 fit_function = self.train_function
1215
D:\Anacona3\envs\tf_gpuu\lib\site-packages\keras\engine\training.py in _make_train_function(self)
314 training_updates = self.optimizer.get_updates(
315 params=self._collected_trainable_weights,
--> 316 loss=self.total_loss)
317 updates = self.updates + training_updates
318
D:\Anacona3\envs\tf_gpuu\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
89 warnings.warn('Update your `' + object_name + '` call to the ' +
90 'Keras 2 API: ' + signature, stacklevel=2)
---> 91 return func(*args, **kwargs)
92 wrapper._original_function = func
93 return wrapper
D:\Anacona3\envs\tf_gpuu\lib\site-packages\keras\backend\tensorflow_backend.py in symbolic_fn_wrapper(*args, **kwargs)
73 if _SYMBOLIC_SCOPE.value:
74 with get_graph().as_default():
---> 75 return func(*args, **kwargs)
76 else:
77 return func(*args, **kwargs)
D:\Anacona3\envs\tf_gpuu\lib\site-packages\keras\optimizers.py in get_updates(self, loss, params)
274 new_a = self.rho * a + (1. - self.rho) * K.square(g)
275 self.updates.append(K.update(a, new_a))
--> 276 new_p = p - lr * g / (K.sqrt(new_a) + self.epsilon)
277
278 # Apply constraints.
D:\Anacona3\envs\tf_gpuu\lib\site-packages\tensorflow_core\python\ops\math_ops.py in binary_op_wrapper(x, y)
901 try:
902 y = ops.convert_to_tensor_v2(
--> 903 y, dtype_hint=x.dtype.base_dtype, name="y")
904 except TypeError:
905 # If the RHS is not a tensor, it might be a tensor aware object
D:\Anacona3\envs\tf_gpuu\lib\site-packages\tensorflow_core\python\framework\ops.py in convert_to_tensor_v2(value, dtype, dtype_hint, name)
1240 name=name,
1241 preferred_dtype=dtype_hint,
-> 1242 as_ref=False)
1243
1244
D:\Anacona3\envs\tf_gpuu\lib\site-packages\tensorflow_core\python\framework\ops.py in internal_convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, ctx, accept_composite_tensors)
1294
1295 if ret is None:
-> 1296 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
1297
1298 if ret is NotImplemented:
D:\Anacona3\envs\tf_gpuu\lib\site-packages\tensorflow_core\python\framework\constant_op.py in _constant_tensor_conversion_function(v, dtype, name, as_ref)
284 as_ref=False):
285 _ = as_ref
--> 286 return constant(v, dtype=dtype, name=name)
287
288
D:\Anacona3\envs\tf_gpuu\lib\site-packages\tensorflow_core\python\framework\constant_op.py in constant(value, dtype, shape, name)
225 """
226 return _constant_impl(value, dtype, shape, name, verify_shape=False,
--> 227 allow_broadcast=True)
228
229
D:\Anacona3\envs\tf_gpuu\lib\site-packages\tensorflow_core\python\framework\constant_op.py in _constant_impl(value, dtype, shape, name, verify_shape, allow_broadcast)
263 tensor_util.make_tensor_proto(
264 value, dtype=dtype, shape=shape, verify_shape=verify_shape,
--> 265 allow_broadcast=allow_broadcast))
266 dtype_value = attr_value_pb2.AttrValue(type=tensor_value.tensor.dtype)
267 const_tensor = g.create_op(
D:\Anacona3\envs\tf_gpuu\lib\site-packages\tensorflow_core\python\framework\tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape, allow_broadcast)
435 else:
436 if values is None:
--> 437 raise ValueError("None values not supported.")
438 # if dtype is provided, forces numpy array to be the type
439 # provided if possible.
ValueError: None values not supported.