小编Shu*_*h77的帖子

ValueError:尺寸必须相等,但对于'Mul'(op:'Mul'),输入形状为784和500:[?,784],[784,500]

我正在尝试学习Tensor Flow,所以我通过https://pythonprogramming.net/tensorflow-neural-network-session-machine-learning-tutorial/关注了神经网络的教程.

我正在尝试运行代码,但即使我的尺寸看起来正确,也要保持相同的尺寸错误.

我是Tensor Flow的新手,所以我不确定我做错了什么.

我会发布代码和错误.

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data

mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)



n_nodes_hl1 = 500
n_nodes_hl2 = 500
n_nodes_hl3 = 500

n_classes = 10
batch_size = 100

x = tf.placeholder('float', [None,784])
y = tf.placeholder('float')

def neural_network_model(data):
    #(input_data * weights) + biases


    hidden_1_layer = {
        'weights' : tf.Variable(tf.random_normal([784,n_nodes_hl1])),
        'biases' : tf.Variable(tf.random_normal([n_nodes_hl1]))
    }


     hidden_2_layer = {
        'weights' :                           tf.Variable(tf.random_normal([n_nodes_hl1,n_nodes_hl2])),
        'biases' : tf.Variable(tf.random_normal([n_nodes_hl2]))
    }
    hidden_3_layer = {
        'weights' : tf.Variable(tf.random_normal([n_nodes_hl2,n_nodes_hl3])),
        'biases' : tf.Variable(tf.random_normal([n_nodes_hl3]))
    }
    output_layer …
Run Code Online (Sandbox Code Playgroud)

python machine-learning python-2.7 tensorflow

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

标签 统计

machine-learning ×1

python ×1

python-2.7 ×1

tensorflow ×1