代码:
dataset = tf.data.Dataset.from_tensor_slices((filenames, labels))
dataset = dataset.map(_parseJpeg, num_parallel_calls = nthread)
dataset = dataset.batch(batch_size)
dataset = dataset.prefetch(batch_size)
iterator = dataset.make_one_shot_iterator()
images, labels = iterator.get_next()
with tf.Session() as sess:
sess.run([images, labels])
回溯(最近通话最近): _do_call中的文件“ D:\ Python \ Anaconda \ envs \ tf \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,行1278 返回fn(* args) 文件“ D:\ Python \ Anaconda \ envs \ tf \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,行1263,在_run_fn中 选项,feed_dict,fetch_list,target_list,run_metadata) _call_tf_sessionrun中的文件“ D:\ Python \ Anaconda \ envs \ tf \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,行1350 run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError:NewRandomAccessFile创建/打开失败:Tensor(“ arg0:0”,shape =(),dtype = string):文件名,目录名或卷标语法不正确。 ;未知错误 [[节点:ReadFile = ReadFile]] [[Node:IteratorGetNext = IteratorGetNextoutput_shapes = [[?, 224,224,3],[?,1000]],output_types = [DT_FLOAT,DT_FLOAT],_device =“ / job:localhost / replica:0 / task:0 / device: CPU:0“]] [[[节点:IteratorGetNext / _1 = _Recvclient_terminated = false,recv_device =“ / job:localhost /副本:0 / task:0 / device:GPU:0”,send_device =“ / job:localhost /副本:0 / task:0 / device:CPU:0“,send_device_incarnation = 1,tensor_name =” edge_37_IteratorGetNext“,tensor_type = DT_FLOAT,_device =” / job:localhost /副本:0 / task:0 / device:GPU:0“]]
在处理上述异常期间,发生了另一个异常:
回溯(最近通话最近): 文件“ vgg16_train_batch_processing.py”,第231行,位于 sess.run(优化程序) 运行中的文件“ D:\ Python \ Anaconda \ envs \ tf \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,行877 run_metadata_ptr) _run中的文件“ D:\ Python \ Anaconda \ envs \ tf \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,行1100 feed_dict_tensor,选项,run_metadata) 文件“ D:\ Python \ Anaconda \ envs \ tf \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,行1272,在_do_run中 run_metadata) _do_call中的文件“ D:\ Python \ Anaconda \ envs \ tf \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,行1291 提高类型(e)(node_def,op,消息) tensorflow.python.framework.errors_impl.InvalidArgumentError:NewRandomAccessFile创建/打开失败:Tensor(“ arg0:0”,shape =(),dtype = string):文件名,目录名或卷标语法不正确。 ;未知错误 [[节点:ReadFile = ReadFile]] [[Node:IteratorGetNext = IteratorGetNextoutput_shapes = [[?, 224,224,3],[?,1000]],output_types = [DT_FLOAT,DT_FLOAT],_device =“ / job:localhost / replica:0 / task:0 / device: CPU:0“]] [[[节点:IteratorGetNext / _1 = _Recvclient_terminated = false,recv_device =“ / job:localhost /副本:0 / task:0 / device:GPU:0”,send_device =“ / job:localhost /副本:0 / task:0 / device:CPU:0“,send_device_incarnation = 1,tensor_name =” edge_37_IteratorGetNext“,tensor_type = DT_FLOAT,_device =” / job:localhost /副本:0 / task:0 / device:GPU:0“]]
答案 0 :(得分:0)
没关系,自己解决问题。
它在数据集地图的解析器功能中。
我错误地放了tf.read_file(filename)
,而不是tf.read_file(str(filename))
,
导致错误的原因是filename
是张量。