相关疑难解决方法(0)

InvalidArgumentError: 发现 2 个根错误。Tensorflow 文本分类模型中不兼容的形状

我正在尝试从以下存储库中获取代码,该存储库基于本文。它有很多错误,但我主要让它工作。但是,我一直遇到同样的问题,我真的不明白如何解决这个问题/甚至出了什么问题。

第二次验证是否满足语句标准时发生错误。第一次总是有效,然后在第二次中断。如果有帮助,我将包括它在中断之前打印的输出。请参阅下面的错误:

step = 1, train_loss = 1204.7784423828125, train_accuracy = 0.13725490868091583
counter = 1, dev_loss = 1188.6639287274584, dev_accuacy = 0.2814199453625912
step = 2, train_loss = 1000.983154296875, train_accuracy = 0.26249998807907104
---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py in _do_call(self, fn, *args)
   1364     try:
-> 1365       return fn(*args)
   1366     except errors.OpError as e:

7 frames
InvalidArgumentError: 2 root error(s) found.
  (0) Invalid argument: Incompatible shapes: [2,185] vs. [2,229]
	 [[{{node loss/cond/add_1}}]]
	 [[viterbi_decode/cond/rnn_1/while/Switch_3/_541]]
  (1) Invalid argument: Incompatible shapes: [2,185] …
Run Code Online (Sandbox Code Playgroud)

python nlp text-classification deep-learning tensorflow

10
推荐指数
1
解决办法
1万
查看次数

tensorflow.equal()上的形状不相容,用于正确的预测评估

使用Tensorflow的MNIST教程,我尝试使用"面部数据库"创建一个用于人脸识别的卷积网络.

图像大小为112x92,我使用3个卷积层将其减少到6 x 5,如此处所示

我在卷积网络上非常新,我的大部分层声明是通过类比Tensorflow MNIST教程制作的,它可能有点笨拙,所以请随时向我提出建议.

x_image = tf.reshape(x, [-1, 112, 92, 1])

h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)
h_pool1 = max_pool_2x2(h_conv1)

W_conv2 = weight_variable([5, 5, 32, 64])
b_conv2 = bias_variable([64])
h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2)
h_pool2 = max_pool_2x2(h_conv2)

W_conv3 = weight_variable([5, 5, 64, 128])
b_conv3 = bias_variable([128])
h_conv3 = tf.nn.relu(conv2d(h_pool2, W_conv3) + b_conv3)
h_pool3 = max_pool_2x2(h_conv3)

W_conv4 = weight_variable([5, 5, 128, 256])
b_conv4 = bias_variable([256])
h_conv4 = tf.nn.relu(conv2d(h_pool3, W_conv4) + b_conv4) …
Run Code Online (Sandbox Code Playgroud)

neural-network conv-neural-network tensorflow

6
推荐指数
1
解决办法
5520
查看次数