我正在尝试将MNIST图像用于许多分类器,但是由于某种原因,它现在会产生此错误。 (之前是正确的,但我更改了InceptionV3的来源)。 这是提供的错误:
InvalidArgumentError Traceback (most recent call last)
~\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\framework\ops.py in _create_c_op(graph, node_def, inputs, control_inputs)
1627 try:
-> 1628 c_op = c_api.TF_FinishOperation(op_desc)
1629 except errors.InvalidArgumentError as e:
InvalidArgumentError: Negative dimension size caused by subtracting 3 from 1 for 'InceptionV3/InceptionV3/Mixed_6a/Branch_0/Conv2d_1a_1x1/Conv2D' (op: 'Conv2D') with input shapes: [?,1,1,288], [3,3,288,384].
在处理上述异常期间,发生了另一个异常:
ValueError Traceback (most recent call last)
<ipython-input-6-db92b294fe8d> in <module>
----> 1 fileImg1.play("Saliency")
~\OneDrive\Documenti\GitHub\cexplainer\src\Xlib.py in play(self, ex)
193 if (ex not in self.dictImgModel):
194 explainer = self.dictImgExplainer[ex]
--> 195 img = prepareImage(self.name,self.PATH,self.SHAPE_1,self.SHAPE_2,self.dataset,self.X_vec,self.y_vec,explainer,label)
196 self.dictImgModel[ex] = img
197
~\OneDrive\Documenti\GitHub\cexplainer\src\algorithms\KDD.py in prepareImage(name, PATH, SHAPE_1, SHAPE_2, dataset, X_vec, y_vec, explainer, label)
438 with slim.arg_scope(inception.inception_v3_arg_scope()):
439 _, end_points = inception.inception_v3(processed_images, is_training=False,
--> 440 num_classes=10)
441 # Restore the checkpoint
442 sess = tf.Session(graph=graph)
~\AppData\Roaming\Python\Python36\site-packages\tensorflow\contrib\slim\python\slim\nets\inception_v3.py in inception_v3(inputs, num_classes, is_training, dropout_keep_prob, min_depth, depth_multiplier, prediction_fn, spatial_squeeze, reuse, scope)
578 scope=scope,
579 min_depth=min_depth,
--> 580 depth_multiplier=depth_multiplier)
581
582 # Auxiliary Head logits
一些建议?
答案 0 :(得分:0)
MNIST是1个通道图像的集合。所有经过预训练的模型都使用3通道(rgb)图像。您可以重复3次单通道图像来绕过此冲突。