TensorFlow 2.12.0训练模型时出现Placeholder占位符警告的问题咨询
TensorFlow 2.12.0训练模型时出现Placeholder占位符警告的问题咨询
我在用TensorFlow 2.12.0训练一个简单模型时,遇到了一个让我有点在意的警告。虽然提示里明确说可以忽略,但我总觉得可能哪里有潜在问题,不想就这么无视它,而且就算设置verbose=0,这个警告还是会跳出来。
警告内容如下:
I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'Placeholder/_1' with dtype double and shape [5000,25,1]
[[{{node Placeholder/_1}}]]
以下是我用来复现问题的极简代码:
import numpy as np from keras import Model from keras.layers import Input, Flatten, Dense, Reshape import tensorflow as tf x = np.random.rand(5000, 10, 7) y = np.random.rand(5000, 25, 1) ############################################################# # 创建数据集 ############################################################# ds = tf.data.Dataset.from_tensor_slices((x, y)) ds = ds.batch(32, drop_remainder=True) ############################################################# # 构建模型 ############################################################# inputs = [] x = Input(shape=(10, 7)) inputs.append(x) x = Flatten()(x) x = Dense(25)(x) x = Reshape((25, 1))(x) model = Model(inputs=inputs, outputs=x) model.compile(loss="mse") model.summary() ############################################################# # 训练模型 ############################################################# model.fit(ds, batch_size=10, verbose=1, epochs=10)
运行代码后的完整输出:
2023-04-10 17:32:46.805357: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2023-04-10 17:32:47.312460: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT 2023-04-10 17:32:50.162190: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1635] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 2578 MB memory: -> device: 0, name: Quadro T1000, pci bus id: 0000:01:00.0, compute capability: 7.5 Model: "model" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= input_1 (InputLayer) [(None, 10, 7)] 0 flatten (Flatten) (None, 70) 0 dense (Dense) (None, 25) 1775 reshape (Reshape) (None, 25, 1) 0 ================================================================= Total params: 1,775 Trainable params: 1,775 Non-trainable params: 0 _________________________________________________________________ Epoch 1/10 2023-04-10 17:32:50.244149: I tensorflow/core/common_runtime/executor.cc:1197] [/device:CPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INVALID_ARGUMENT: You must feed a value for placeholder tensor 'Placeholder/_1' with dtype double and shape [5000,25,1] [[{{node Placeholder/_1}}]] 2023-04-10 17:32:50.804972: I tensorflow/compiler/xla/service/service.cc:169] XLA service 0x7f6e808f79c0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices: 2023-04-10 17:32:50.804996: I tensorflow/compiler/xla/service/service.cc:177] StreamExecutor device (0): Quadro T1000, Compute Capability 7.5 2023-04-10 17:32:50.807856: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:269] disabling MLIR crash reproducer, set env var `MLIR_CRASH_REPRODUCER_DIRECTORY` to enable. 2023-04-10 17:32:50.909253: I tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:424] Loaded cuDNN version 8600 2023-04-10 17:32:50.946872: I tensorflow/tsl/platform/default/subprocess.cc:304] Start cannot spawn child process: No such file or directory 2023-04-10 17:32:50.981030: I ./tensorflow/compiler/jit/device_compiler.h:180] Compiled cluster using XLA! This line is logged at most once for the lifetime of the process. 156/156 [==============================] - 1s 986us/step - loss: 0.2249 Epoch 2/10 156/156 [==============================] - 0s 958us/step - loss: 0.1457 Epoch 3/10 156/156 [==============================] - 0s 981us/step - loss: 0.1185 Epoch 4/10 156/156 [==============================] - 0s 929us/step - loss: 0.1026 Epoch 5/10 156/156 [==============================] - 0s 1ms/step - loss: 0.0940 Epoch 6/10 156/156 [==============================] - 0s 929us/step - loss: 0.0895 Epoch 7/10 156/156 [==============================] - 0s 960us/step - loss: 0.0872 Epoch 8/10 156/156 [==============================] - 0s 958us/step - loss: 0.0860 Epoch 9/10 156/156 [==============================] - 0s 969us/step - loss: 0.0854 Epoch 10/10 156/156 [==============================] - 0s 998us/step - loss: 0.0851 Process finished with exit code 0
备注:内容来源于stack exchange,提问作者Gustav-Gans
相关产品推荐
相关产品推荐

