tensorflow---错误input

错误提示:

OutOfRangeError (see above for traceback): RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 128, current size 0)
     [[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

 

 

是数据维度,或者其他的不把匹配,请仔细检查

我这里的原因是因为我数据在写书tf.record的时候,我使用的数据类型float32,

而我在读取tf.record的时候我使用来float32,如下所示:

img = tf.decode_raw(features['img_raw'], tf.float32) img = tf.reshape(img, [33, 33, 4])

所以一定要仔细检查

TensorFlow Estimator是TensorFlow的高级API之一,用于简化模型训练和评估的过程。要验证TensorFlow Estimator是否可以使用,你可以完成以下步骤: 1. 确认你已经安装了TensorFlow。可以在Python控制台中输入以下命令:`import tensorflow as tf`。如果没有出现错误,则说明TensorFlow已经被成功安装。 2. 确认你已经安装了TensorFlow Estimator。可以在Python控制台中输入以下命令:`import tensorflow_estimator as tfest`。如果没有出现错误,则说明TensorFlow Estimator已经被成功安装。 3. 编写一个简单的TensorFlow Estimator模型,并使用它来训练和评估数据集。以下是一个示例代码: ```python import tensorflow as tf import tensorflow_estimator as tfest # 准备数据集 (x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data() x_train = x_train / 255.0 x_test = x_test / 255.0 y_train = tf.keras.utils.to_categorical(y_train) y_test = tf.keras.utils.to_categorical(y_test) # 定义特征列 feature_columns = [tf.feature_column.numeric_column("x", shape=[28, 28])] # 定义Estimator estimator = tfest.DNNClassifier( feature_columns=feature_columns, hidden_units=[256, 32], optimizer=tf.optimizers.Adam(learning_rate=0.001), n_classes=10, model_dir="./model" ) # 训练模型 train_input_fn = tf.estimator.inputs.numpy_input_fn( x={"x": x_train}, y=y_train, batch_size=128, num_epochs=None, shuffle=True ) estimator.train(input_fn=train_input_fn, steps=1000) # 评估模型 test_input_fn = tf.estimator.inputs.numpy_input_fn( x={"x": x_test}, y=y_test, num_epochs=1, shuffle=False ) eval_results = estimator.evaluate(input_fn=test_input_fn) print(eval_results) ``` 4. 运行代码,如果没有出现错误并且能够正确训练和评估模型,则说明TensorFlow Estimator可以使用。 总之,如果你已经成功地安装了TensorFlowTensorFlow Estimator,并且可以使用它们来训练和评估模型,则说明它们可以正常使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值