首页 > 编程学习 > VGG训练报错:Errors may have originated from an input operation.

利用自己做的数据集训练VGG时,出现报错信息:

Errors may have originated from an input operation.
Input Source operations connected to node conv0/Conv1/Conv2D:
IteratorGetNext (defined at train_resnet.py:95)

Input Source operations connected to node conv0/Conv1/Conv2D:
IteratorGetNext (defined at train_resnet.py:95)

Original stack trace for ‘conv0/Conv1/Conv2D’:
File “train_resnet.py”, line 103, in
logits = model.build(images, 2)
File “/home/nuaa301/yangshuang/MathModel/ResNet/model_resnet.py”, line 87, in build
net = self._conv_layer(input, 16, tf.nn.relu, name=‘Conv1’) # 48x48
File “/home/nuaa301/yangshuang/MathModel/ResNet/model_resnet.py”, line 14, in _conv_layer
name=name)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py”, line 324, in new_func
return func(*args, **kwargs)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/layers/convolutional.py”, line 424, in conv2d
return layer.apply(inputs)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py”, line 1479, in apply
return self.call(inputs, *args, **kwargs)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/layers/base.py”, line 537, in call
outputs = super(Layer, self).call(inputs, *args, **kwargs)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py”, line 634, in call
outputs = call_fn(inputs, *args, **kwargs)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/autograph/impl/api.py”, line 146, in wrapper
), args, kwargs)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/autograph/impl/api.py”, line 446, in converted_call
return _call_unconverted(f, args, kwargs)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/autograph/impl/api.py”, line 253, in _call_unconverted
return f(*args, **kwargs)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/keras/layers/convolutional.py”, line 196, in call
outputs = self._convolution_op(inputs, self.kernel)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py”, line 1079, in call
return self.conv_op(inp, filter)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py”, line 635, in call
return self.call(inp, filter)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py”, line 234, in call
name=self.name)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py”, line 1953, in conv2d
name=name)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/ops/gen_nn_ops.py”, line 1071, in conv2d
data_format=data_format, dilations=dilations, name=name)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py”, line 788, in _apply_op_helper
op_def=op_def)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py”, line 507, in new_func
return func(*args, **kwargs)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”, line 3616, in create_op
op_def=op_def)
File “/home/nuaa301/anaconda3/envs/yang/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”, line 2005, in init
self._traceback = tf_stack.extract_stack()

原因:
可能是数据集图片的尺寸和神经网络要求不匹配。
解决方案:
将训练集图片的像素尺寸修改为224像素224像素后,即可解决。
对于ResNet网络也要求输入图像的尺寸为224像素
224像素。

Copyright © 2010-2022 ngui.cc 版权所有 |关于我们| 联系方式| 豫B2-20100000