报错分析"D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\Scripts\python.exe" "D:/2025College Student Innovation and Entrepreneurship Project/project/VGG/VGG.py"
显存动态分配成功!
2025-08-12 18:47:20.493861: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2025-08-12 18:47:20.614079: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1510] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 5563 MB memory: -> device: 0, name: NVIDIA GeForce RTX 4060 Laptop GPU, pci bus id: 0000:01:00.0, compute capability: 8.9
Model: "model"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_layer (InputLayer) [(128, 224, 224, 3)] 0
_________________________________________________________________
conv2d (Conv2D) (128, 224, 224, 64) 1792
_________________________________________________________________
max_pooling2d (MaxPooling2D) (128, 112, 112, 64) 0
_________________________________________________________________
conv2d_1 (Conv2D) (128, 112, 112, 128) 73856
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (128, 56, 56, 128) 0
_________________________________________________________________
conv2d_2 (Conv2D) (128, 56, 56, 256) 295168
_________________________________________________________________
conv2d_3 (Conv2D) (128, 56, 56, 256) 590080
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (128, 28, 28, 256) 0
_________________________________________________________________
conv2d_4 (Conv2D) (128, 28, 28, 512) 1180160
_________________________________________________________________
conv2d_5 (Conv2D) (128, 28, 28, 512) 2359808
_________________________________________________________________
max_pooling2d_3 (MaxPooling2 (128, 14, 14, 512) 0
_________________________________________________________________
conv2d_6 (Conv2D) (128, 14, 14, 512) 2359808
_________________________________________________________________
conv2d_7 (Conv2D) (128, 14, 14, 512) 2359808
_________________________________________________________________
max_pooling2d_4 (MaxPooling2 (128, 7, 7, 512) 0
_________________________________________________________________
flatten (Flatten) (128, 25088) 0
_________________________________________________________________
dense (Dense) (128, 4096) 102764544
_________________________________________________________________
dropout (Dropout) (128, 4096) 0
_________________________________________________________________
dense_1 (Dense) (128, 4096) 16781312
_________________________________________________________________
dropout_1 (Dropout) (128, 4096) 0
_________________________________________________________________
dense_2 (Dense) (128, 1000) 4097000
=================================================================
Total params: 132,863,336
Trainable params: 132,863,336
Non-trainable params: 0
_________________________________________________________________
Epoch 1/100
Traceback (most recent call last):
File "D:/2025College Student Innovation and Entrepreneurship Project/project/VGG/VGG.py", line 1011, in <module>
callbacks=[reduce_lr] # 添加回调函数
File "D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\keras\engine\training.py", line 1184, in fit
tmp_logs = self.train_function(iterator)
File "D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\eager\def_function.py", line 885, in __call__
result = self._call(*args, **kwds)
File "D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\eager\def_function.py", line 933, in _call
self._initialize(args, kwds, add_initializers_to=initializers)
File "D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\eager\def_function.py", line 760, in _initialize
*args, **kwds))
File "D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\eager\function.py", line 3066, in _get_concrete_function_internal_garbage_collected
graph_function, _ = self._maybe_define_function(args, kwargs)
File "D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\eager\function.py", line 3463, in _maybe_define_function
graph_function = self._create_graph_function(args, kwargs)
File "D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\eager\function.py", line 3308, in _create_graph_function
capture_by_value=self._capture_by_value),
File "D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\framework\func_graph.py", line 1007, in func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
File "D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\eager\def_function.py", line 668, in wrapped_fn
out = weak_wrapped_fn().__wrapped__(*args, **kwds)
File "D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\framework\func_graph.py", line 994, in wrapper
raise e.ag_error_metadata.to_exception(e)
ValueError: in user code:
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\keras\engine\training.py:853 train_function *
return step_function(self, iterator)
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\keras\engine\training.py:842 step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:1286 run
return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:2849 call_for_each_replica
return self._call_for_each_replica(fn, args, kwargs)
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\distribute\distribute_lib.py:3632 _call_for_each_replica
return fn(*args, **kwargs)
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\keras\engine\training.py:835 run_step **
outputs = model.train_step(data)
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\keras\engine\training.py:789 train_step
y, y_pred, sample_weight, regularization_losses=self.losses)
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\keras\engine\compile_utils.py:184 __call__
self.build(y_pred)
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\keras\engine\compile_utils.py:133 build
self._losses = tf.nest.map_structure(self._get_loss_object, self._losses)
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\util\nest.py:869 map_structure
structure[0], [func(*x) for x in entries],
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\tensorflow\python\util\nest.py:869 <listcomp>
structure[0], [func(*x) for x in entries],
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\keras\engine\compile_utils.py:273 _get_loss_object
loss = losses_mod.get(loss)
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\keras\losses.py:2136 get
return deserialize(identifier)
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\keras\losses.py:2095 deserialize
printable_module_name='loss function')
D:\2025College Student Innovation and Entrepreneurship Project\environment\py3.6(tf2.6+cuda11.2+cudnn8.1)\lib\site-packages\keras\utils\generic_utils.py:709 deserialize_keras_object
.format(printable_module_name, object_name))
ValueError: Unknown loss function: sparse_softmax_cross_entropy_with_logits. Please ensure this object is passed to the `custom_objects` argument. See https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object for details.
Process finished with exit code 1