Проблема с весами в тензорном потоке

#python #tensorflow #keras

#питон #тензорный поток #keras

Вопрос:

Вот журналы о проблеме с терминала в VS, так как я замечаю, что проблема связана с весом и сетью50:

 2021-12-09 14:13:05.990253: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll Found 1150 images belonging to 6 classes. Found 69 images belonging to 3 classes. 2021-12-09 14:13:07.597333: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library nvcuda.dll 2021-12-09 14:13:07.620200: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1733] Found device 0 with properties: pciBusID: 0000:08:00.0 name: GeForce GT 710 computeCapability: 3.5 coreClock: 0.954GHz coreCount: 1 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 37.33GiB/s 2021-12-09 14:13:07.620290: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll 2021-12-09 14:13:07.626040: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublas64_11.dll 2021-12-09 14:13:07.626153: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublasLt64_11.dll 2021-12-09 14:13:07.629388: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cufft64_10.dll 2021-12-09 14:13:07.630584: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library curand64_10.dll 2021-12-09 14:13:07.634544: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cusolver64_11.dll 2021-12-09 14:13:07.637477: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cusparse64_11.dll 2021-12-09 14:13:07.638137: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudnn64_8.dll 2021-12-09 14:13:07.638274: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1871] Adding visible gpu devices: 0 2021-12-09 14:13:07.638762: 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. 2021-12-09 14:13:07.639495: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1733] Found device 0 with properties: pciBusID: 0000:08:00.0 name: GeForce GT 710 computeCapability: 3.5 coreClock: 0.954GHz coreCount: 1 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 37.33GiB/s 2021-12-09 14:13:07.639637: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1871] Adding visible gpu devices: 0 2021-12-09 14:13:08.054229: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1258] Device interconnect StreamExecutor with strength 1 edge matrix: 2021-12-09 14:13:08.054494: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1264] 0 2021-12-09 14:13:08.055724: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1277] 0: N 2021-12-09 14:13:08.056304: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1418] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1401 MB memory) -gt; physical GPU (device: 0, name: GeForce GT 710, pci bus id: 0000:08:00.0, compute capability: 3.5) 2021-12-09 14:13:09.783481: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:176] None of the MLIR Optimization Passes are enabled (registered 2) Epoch 1/20 2021-12-09 14:13:11.729552: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudnn64_8.dll 2021-12-09 14:13:11.994194: I tensorflow/stream_executor/cuda/cuda_dnn.cc:359] Loaded cuDNN version 8100 2021-12-09 14:13:12.881136: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublas64_11.dll 2021-12-09 14:13:13.119825: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublasLt64_11.dll Traceback (most recent call last):  File "C:Tensorflowworkspacetraining_demotraining21.py", line 47, in lt;modulegt;  model.fit(train_generator, steps_per_epoch=3, epochs=20, validation_data=validation_generator, validation_steps=1)  File "C:Userskamil.condaenvstensorflowlibsite-packagestensorflowpythonkerasenginetraining.py", line 1183, in fit  tmp_logs = self.train_function(iterator)  File "C:Userskamil.condaenvstensorflowlibsite-packagestensorflowpythoneagerdef_function.py", line 889, in __call__  result = self._call(*args, **kwds)  File "C:Userskamil.condaenvstensorflowlibsite-packagestensorflowpythoneagerdef_function.py", line 950, in _call  return self._stateless_fn(*args, **kwds)  File "C:Userskamil.condaenvstensorflowlibsite-packagestensorflowpythoneagerfunction.py", line 3023, in __call__  return graph_function._call_flat(  File "C:Userskamil.condaenvstensorflowlibsite-packagestensorflowpythoneagerfunction.py", line 1960, in _call_flat  return self._build_call_outputs(self._inference_function.call(  File "C:Userskamil.condaenvstensorflowlibsite-packagestensorflowpythoneagerfunction.py", line 591, in call  outputs = execute.execute(  File "C:Userskamil.condaenvstensorflowlibsite-packagestensorflowpythoneagerexecute.py", line 59, in quick_execute  tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name, tensorflow.python.framework.errors_impl.InvalidArgumentError: logits and labels must be broadcastable: logits_size=[24,10] labels_size=[24,6]  [[node categorical_crossentropy/softmax_cross_entropy_with_logits (defined at Tensorflowworkspacetraining_demotraining21.py:47) ]] [Op:__inference_train_function_9664]  Function call stack: train_function  2021-12-09 14:13:20.601044: W tensorflow/core/kernels/data/generator_dataset_op.cc:107] Error occurred when finalizing GeneratorDataset iterator: Failed precondition: Python interpreter state is not initialized. The process may be terminated.  [[{{node PyFunc}}]]  

Мой самый первый проект Tensorflow, пожалуйста, помогите решить эту проблему. Я использую предварительно обученную модель и свои собственные фотографии, а также свой собственный файл json с 3 классами для распознавания объектов. Заранее большое вам спасибо!

 image_size = 224  data_generator_with_aug = ImageDataGenerator(preprocessing_function=preprocess_input,   horizontal_flip=True,  width_shift_range=0.2,  height_shift_range=0.2) train_path='C:/Tensorflow/workspace/training_demo/training2/training' train_generator = data_generator_with_aug.flow_from_directory(train_path,   target_size=(image_size, image_size),   batch_size=24,  class_mode='categorical')  data_generator_with_no_aug = ImageDataGenerator(preprocessing_function=preprocess_input)  validation_path='C:/Tensorflow/workspace/training_demo/training2/validation' validation_generator = data_generator_with_no_aug.flow_from_directory(validation_path,  target_size=(image_size, image_size),  batch_size=24,  class_mode='categorical')     #resnet_weights_path = 'imagenet'  model = Sequential() model.add(ResNet50(include_top=False, pooling='avg', weights='imagenet'))  num_classes = 10 model.add(Dense(num_classes, activation='softmax'))  model.layers[0].trainable = False  model.compile(optimizer='sgd', loss='categorical_crossentropy', metrics=['accuracy'])  model.fit(train_generator, steps_per_epoch=3, epochs=20, validation_data=validation_generator, validation_steps=1)  

Комментарии:

1. Ваша обратная связь неполна, в ней не указано, какая ошибка/исключение произошла.

2. Я добавляю весь текст из терминала, который, как я понимаю, вы хотите увидеть

3. Вполне вероятно, что путь, который вы передали в качестве веса, не существует (os.path.exists на этом пути возвращает False).

4. Я меняю путь, но проблема все еще существует

5. Что возвращает os.path.exists на вашем пути?